Computer Vision - Experiment 7 - Find and draw outline experiments
Experimental objectives and requirements
Understand the basic principle of finding image contours; master the code writing method of finding contours using OpenCV; master the code writing method of drawing contours using OpenCV.
Experiment content
(i) New project.
(ii) Configuring OpenCV in VS2015.
(iii) Using the findContours function in OpenCV to implement find contours;
(iv) Use the drawContours function in OpenCV to implement draw contours.
Experimental instruments, equipment
A computer with Windows 7 operating system and Visual Studio 2015 installed
Experimental principle
(i) Although an edge detection algorithm like Canny can detect pixels at the boundary of the contours based on the difference between pixels, it does not take the contours as a whole. So, this experiment is to assemble these edge pixels into a contour.
(ii) A contour generally corresponds to a series of points, which is a curve in the image. Its representation may vary depending on the situation. In OpenCV, the findContours function can be used to find contours from a binary image. drawContours function is used to draw external or internal contours in the image .
Experimental steps
(i) Create a Visual Studio 2015 console application;
(ii) Configure OpenCV in Visual Studio 2015;
(iii) Write code to implement findContours using the findContours function to implement find contours;
(iv) Write code to implement drawContours using the drawContours function.
Experimental notes
(i) The method of configuring OpenCV in VS after completing the installation of OpenCV;
(ii) The functions and usage of the findContours function;
(iii) The functions and usage of the drawContours function.
Experimental results
(i) experimental code
|
|
(ii) Show results
Experiment Summary
The main content of this experiment is to understand the basic principle of finding image contours; to master the code writing method of using OpenCV to implement find contours; to master the code writing method of using OpenCV to implement draw contours. Create a new project, configure OpenCV in VS2015, and use the findContours function in OpenCV to find contours; use the drawContours function in OpenCV to draw contours. Learn how to find contours from binary images with the findContours function. drawContours function is used to draw external or internal contours in an image.