opencv_tutorials_t5
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
opencv_tutorials_t5 [2016/06/07 15:54] – joaomatos | opencv_tutorials_t5 [2017/05/13 17:44] (current) – [Understanding the code] acater | ||
---|---|---|---|
Line 4: | Line 4: | ||
Doing the threshold is very simple , just adjust the slider bars created on the trackbar window to filter the color that you want , move the bars to make the object that you want as white , and all the other undesired object as black. | Doing the threshold is very simple , just adjust the slider bars created on the trackbar window to filter the color that you want , move the bars to make the object that you want as white , and all the other undesired object as black. | ||
+ | |||
I recommend you to type the code on your own to get familiarized with the program language. If you have trouble , the original code is attached bellow ( Running on Visual Studio 2015 + OpenCV 3.1 ) * Check the installation guide to make sure that you linked all the OpenCV modules to your Visual Studio. | I recommend you to type the code on your own to get familiarized with the program language. If you have trouble , the original code is attached bellow ( Running on Visual Studio 2015 + OpenCV 3.1 ) * Check the installation guide to make sure that you linked all the OpenCV modules to your Visual Studio. | ||
Line 48: | Line 49: | ||
const int FRAME_HEIGHT = 480; | const int FRAME_HEIGHT = 480; | ||
- | //Function to create a window with the Trackbars to apply the Thresholding. | + | //Function to create a window with the Trackbars to apply the Threshold. |
void createTrackbars() { | void createTrackbars() { | ||
Line 75: | Line 76: | ||
//Defining the erode and dilate properties | //Defining the erode and dilate properties | ||
//the erode element chosen here is a 3x3 piexels rectangle. | //the erode element chosen here is a 3x3 piexels rectangle. | ||
- | //Change the Size argument to optimize your thresholding. | + | //Change the Size argument to optimize your threshold. |
- | //dilate with 8x8 size element to make the thresholding | + | //dilate with 8x8 size element to make the threshold |
Mat erodeElement = getStructuringElement(MORPH_RECT, | Mat erodeElement = getStructuringElement(MORPH_RECT, | ||
Line 184: | Line 185: | ||
---- | ---- | ||
< | < | ||
- | //Function to create a window with the Trackbars to apply the Thresholding. | + | //Function to create a window with the Trackbars to apply the Threshol. |
void createTrackbars() { | void createTrackbars() { | ||
Line 206: | Line 207: | ||
</ | </ | ||
- | Our first function is the function that will create a window to display the slider bars to adjust the HSV Threshold. First we create a new window using **" | + | Our first function is the function that will create a window to display the slider bars to adjust the HSV Threshold. First we create a new window using **" |
Line 217: | Line 218: | ||
//Defining the erode and dilate properties | //Defining the erode and dilate properties | ||
//the erode element chosen here is a 3x3 piexels rectangle. | //the erode element chosen here is a 3x3 piexels rectangle. | ||
- | //Change the Size argument to optimize your thresholding. | + | //Change the Size argument to optimize your threshold. |
- | //dilate with 8x8 size element to make the thresholding | + | //dilate with 8x8 size element to make the threshold |
Mat erodeElement = getStructuringElement(MORPH_RECT, | Mat erodeElement = getStructuringElement(MORPH_RECT, | ||
Line 326: | Line 327: | ||
| | ||
+ | \\ | ||
+ | \\ | ||
+ | Below is a video demonstrating the program in real time. | ||
+ | {{youtube> |
opencv_tutorials_t5.1465340048.txt.gz · Last modified: by joaomatos