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!
- 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
- (Coming Soon) QR Codes detection on the 🎦 camera feed using OpenCV and Net 5