Computer Vision - Experiment 9 - Find and draw convex packets of objects experimentally
Experimental aims and requirements
Understand the basic principles of using convex packets; master the method of writing code to understand object shapes or corridors by convex packets using OpenCV.
Experiment content
(i) Create a new project.
(ii) Configuring OpenCV in VS2015.
(iii) Finding image contours using the findContours function in OpenCV;
(iv) Iterate over each contour and use convexHull in OpenCV to find its convex package;
(v) Write code to draw the image contours and their convex packages using the drawContours function in OpenCV.
Experimental apparatus, equipment
A computer with Windows 7 operating system and Visual Studio 2015 installed
Experimental principle
(i) Convex Hull is a common concept in computational geometry (graphics). In simple terms, given a set of points on a two-dimensional plane, a convex hull is a convex polygon that connects the outermost points to form a polygon that is capable of containing all the points in the point set. One of the more useful ways to understand the shape or corridor of an object is to compute the convex envelope of an object.
(ii) In OpenCV, the convexHull function is used to find the convex packet of an image point set.
Experimental steps
(i) Create a Visual Studio 2015 console program;
(ii) Configure OpenCV in Visual Studio 2015;
(iii) Write code to find image contours using the findContours function;
(iv) Write code to iterate over each contour and use the convexHull function to find its convex package;
(v) Write code to plot the image contours and their convex packets.
Experimental notes
(i) Configure 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 convexHull function;
(iv) 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 principles of using convex packages; to master the code writing method to understand the shape of objects or corridors by convex packages using OpenCV. Create a new project, configure OpenCV in VS2015, use the findContours function in OpenCV to find the image contours; traverse each contour and use convexHull in OpenCV to find its convex package; write code to draw the image contours and their convexity using the drawContours function in OpenCV. Learn to find the image contours with the findContours function; learn to find their convex packages with the convexHull function; learn to draw the image contours and their convexity with the drawContours function.