I am building software for my startup that uses some components of the free part of opencv. I think the startup is based on a unique idea, so I would like to protect the process of realizing this idea with a US provisional patent. What are the risks(if any) involved?
You may patent anything that meets the normal requirements for patent eligibility, including (but not limited to) the invention is novel, non-obvious, useful, and invented by you. If you add something beyond what OpenCV offers that meets that criteria, you can likely patent your innovation.
The more interesting question is whether you are obligated to license your patent under the OpenCV license, as the patent office doesn't care if you used OSS or not, except as to how such open source may be prior art to your patent. A potential licensee, however, may be able to acquire a license to your patent by operation of the OSS license for OpenCV.
After a cursory search, OpenCV appears to be licensed under a 3-clause BSD license, which doesn't contain a patent grant, so you a little more in the dark about what might happen to your patent than some of the other more definite licenses, however this may be good for your patent. There is likely an implied license grant that kicks in to cover people who use code under the BSD grant (although some would disagree), and how far that license and the accompanying exhaustion may or may not travel is a question that practitioners can't really agree on, so I won't opine here.
Generally, OSS licenses may have different obligations about licensing patents that kick in under use, distribution, and contribution, so depending on what you do with OpenCV, you may end up with different obligations that could effect your patent. The implications to an implied license grant under those scenarios are even more convoluted and you may even get different answers from different courts. That said, if you aren't distributing or contributing to OpenCV, your risk of an implied license grant is much much lower.
For instance, under the GPLv3, if you distribute the work and grant the recipient of the work a patent license, you must grant all who receive the work a patent license, whether they got it from you or not. Depending on your patent claims, your contribution, and your redistribution of code that contains your contribution that embodies your patent, you may be granting a license to everyone to practice your invention (see section 11, Patents, GPLv3) It gets further complicated if you are actively redistributing the work, and someone else contributes an infringing contribution, but you continue to distribute the work. OSS law is very complex and requires quite a bit of knowledge about how the various licenses interplay, and there are many who believe OSS licenses should be interpreted in a particular way (including the license authors) but until a court weighs in, it is a murky area.
Also, you must look at how you use, and distribute, and contribute to OpenCV dependencies as well as OpenCV. You must understand how all the licenses that might come into play overlap and impact your obligations, and you may need an open source lawyer to help you out.
If your idea is novel and inventive over the prior art, patenting it is possible. The only risks are losing the money invested in the patent if it is not granted and disclosing information in the application.
If you want to use the idea, check the license for the free part of opencv, are you allowed to use it commercially?