
Hi !
Back on the Windows Forms days, cameras were tricky. We didn’t have a lot of libraries to work, and they usually require some extra work to handle unexpected errors. With Net 5 and OpenCVSharp, we can create a simple WebCam viewer like this one.

Let’s start with a [Take a Photo] Windows Form app. This App have a PictureBox and a Button, and it’s all connected with these lines.
As you can see it’s super simple, and the main lesson to learn here is on line 27, when we need to convert the OpenCV Mat object to a standard Bitmap to be used on a PictureBox.
We can some more features, like the one in the animation before
- Start / Stop Camera Preview
- Calculate FPS
- Add Canny effect
with the following lines
Less than 100 lines of code to do some camera image processing in WinForms!
That’s all for today!
Happy coding!
Greetings
El Bruno
More posts in my blog ElBruno.com.
More info in https://beacons.ai/elbruno
References
- OpenCVSharp, https://github.com/shimat/opencvsharp
- Wikipedia, Canny Edge Detector
- OpenCV, Canny tutorial
- openCV, FAST tutorial
- Wikipedia, FAST
Net 5 and OpenCV
- 13 lines to display a π¦ camera feed with OpenCV and Net5
- Detecting edges on the π¦ camera feed with Canny algorithm, OpenCV and Net5
- Detecting corners on the π¦ camera feed with FAST algorithm, OpenCV and Net 5
- Display the π¦ camera feed in a WinForm using OpenCV and Net5
- Face Detection using Face Cascades on the π¦ camera feed using OpenCV and Net 5
- Face Detection using DNN on the π¦ camera feed using OpenCV and Net 5
- Face Detection, DNN vs Haar Cascades on the π¦ camera feed using OpenCV and Net 5
- Age and Gender estimation on the π¦ camera feed using OpenCV and Net 5
- Caffe Model Zoo (GoogleNet) detection from the π¦ camera feed using OpenCV and Net5
- Pose detection from the π¦ camera feed using OpenCV and Net5
- Packaging a WinForm OpenCV and Net5 App in a one-self contained file
- Display a video file π₯ in Winform using OpenCV and Net5
- Open a video file π₯ and save each frame as a PNG πΌ file to a folderΒ π
- (Coming Soon) QR Codes detection on the π¦ camera feed using OpenCV and Net 5