Accessing computer components (Camera)

Hi, I was wondering how to open up the camera on a computer using C++. I found the "OpenCV" library, but Visual Studio is a huge pain when it comes to using a new library! That said, is there a way to use the basic C++ library to access the camera without simply opening up the Windows camera app? Thanks.
If by "basic C++ library", you mean the standard C++ library: No.

C++ by itself doesn't know that you have a webcam. You must install a library, it can be confusing but you'll get the hang of it eventually. I struggled a lot when first learning OpenGL. I don't use webcams so I don't know of a particular library, but it looks like OpenCV has some built-in ability to connect to one. Link I found that might help:
https://stackoverflow.com/questions/14187032/opencv-and-connecting-a-webcam
> I found the "OpenCV" library, but Visual Studio is a huge pain when it comes to using a new library!

Use VcPkg https://blogs.msdn.microsoft.com/vcblog/2016/09/19/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows/
Thanks everyone for your replies!

It suppose it makes sense that there's no functionality to open the webcam with C++ standard library. Also, universal apps aren't what I really want, thanks though Thomas.

JLBorges, I tried the VcPkg. I'm not terribly great at figuring out how these packages are to be used and stuff. I haven't been able to get it to work using instructional videos and the quick start guide on the site (which seems to be different than how it was about a year ago when looking at youtube videos). I've run the BAT file and it has created an .exe . This executable only runs for a second. Another version of it in another folder within that one runs the same way. I'm not too sure if I'm doing something wrong or if my laptop is simply not supported. Powershell commands don't work. If you think I'm doing something wrong, let me know.

Thanks again everyone!
See the example here:
https://github.com/Microsoft/vcpkg/blob/master/docs/examples/using-sqlite.md

This example is for using the package sqlite, so substitute opencv for sqllite.

See Step 1: Install and Step 2: Use - VS/MSBuild Project (User-wide integration)
Sorry, I guess I didn't easily clarify. The VcPkg command prompt itself will only open for a split second. In that second, it shows me a list of VcPkg commands. Because of this, I can't enter any commands, which means I can't get anywhere at all. I'm not sure if I did something wrong or if it's simply not compatible. Thanks for your reply, JLBorges!
@zapshe
If the command is only shown or a split second and then goes away, that probably means it's meant for the command to be run in an actual command-line utility (cmd or powershell on windows).

open cmd
cd to the directory that contains your program
run the program (type its name and press enter)

You'll see the same thing happen if you try to run ipconfig or a similar system32 program outside of cmd itself.
Last edited on
@Ganado

Thanks a lot for that! I can get it to work now. Very appreciated :) !
Thanks again everyone ! I just finished with VcPkg and it worked great. This tool is very useful! Thanks a lot for introducing it to me JLBorges. OpenCV works great. Thanks again guys! ^^
Topic archived. No new replies allowed.