# Simple demo code solution for using opencv with visual studio 2019 or therabouts

**URL:** <https://forum.opencv.org/t/simple-demo-code-solution-for-using-opencv-with-visual-studio-2019-or-therabouts/4340>\
**Category:** C++\
**Tags:** windows, build\
**Created:** [July 15, 2021, 7:53am UTC](https://forum.opencv.org/t/simple-demo-code-solution-for-using-opencv-with-visual-studio-2019-or-therabouts/4340 "2021-07-15T07:53:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeffrey](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@Jeffrey](https://forum.opencv.org/u/Jeffrey)\
**Post date:** [July 15, 2021, 7:53am UTC](https://forum.opencv.org/t/simple-demo-code-solution-for-using-opencv-with-visual-studio-2019-or-therabouts/4340/1 "2021-07-15T07:53:14Z")

</div>

Does anyone have a ready made simple demo code solution for using opencv with visual studio 2019 or therabouts . To take one picture from a camera ?

The tutorial refers to versions of visual studio from about 10 years ago.

Also any solution that i could run as is will be very helpfull.

Thanks

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [July 15, 2021, 9:12am UTC](https://forum.opencv.org/t/simple-demo-code-solution-for-using-opencv-with-visual-studio-2019-or-therabouts/4340/2 "2021-07-15T09:12:01Z")

</div>

there are several parts to this

- getting a build OpenCV that’s compatible with VS 2019
- figuring out how to make a VS project that uses OpenCV
- the actual VideoCapture and imwrite stuff

what have you tried? what exactly were the results? where are you stuck?

why aren’t you simply using python?

---

<div class="post-metadata">

**Author:** ![Jeffrey](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@Jeffrey](https://forum.opencv.org/u/Jeffrey)\
**Post date:** [July 15, 2021, 12:11pm UTC](https://forum.opencv.org/t/simple-demo-code-solution-for-using-opencv-with-visual-studio-2019-or-therabouts/4340/3 "2021-07-15T12:11:01Z")

</div>

Well I have preexisting code that is written in C++. Incidentally in Python are there demo programs ready to use as is ?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [July 15, 2021, 3:29pm UTC](https://forum.opencv.org/t/simple-demo-code-solution-for-using-opencv-with-visual-studio-2019-or-therabouts/4340/4 "2021-07-15T15:29:04Z")

</div>

there might be, but it’s so ridiculously trivial that nobody would bother even looking through the tutorials on [docs.opencv.org](http://docs.opencv.org) for this

```python
import numpy as np
import cv2 as cv

cap = cv.VideoCapture(0)
assert cap.isOpened(), "couldn't open the first camera"

rv, frame = cap.read()
assert rv, "camera wouldn't give a frame"

# `frame` is the picture, do whatever

```

I figure your real problem is the toolchain.

browse the docs. use cmake to generate the VS solution for you.

use the official binary release for visual studio 2019 (“vs16”).
