User Tools

Site Tools


opencv_tutorials_t5

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
opencv_tutorials_t5 [2016/06/07 15:54] joaomatosopencv_tutorials_t5 [2017/05/13 17:44] (current) – [Understanding the code] acater
Line 49: 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 76: 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 object more visible+ //dilate with 8x8 size element to make the threshold object more visible
  
  Mat erodeElement = getStructuringElement(MORPH_RECT, Size(3, 3));   Mat erodeElement = getStructuringElement(MORPH_RECT, Size(3, 3));
Line 185: Line 185:
 ---- ----
 <Code:c++ linenums:35> <Code:c++ linenums:35>
-//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 207: Line 207:
 </Code> </Code>
  
-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 **"namedWindow"** to display the slider bars. Each slider bar is created using the command **"cvCreateTrackbar"** . The first argument is the name of the slider bar , the second argument is where it will be displayed (put the same name as the window that you opened using the **namedWindow** ).The third argument is the value that this track bar will store , and the fourth argument is the maximum value that can be assigned.  We need to create six of these sliders, because our thresholding will be made between a minimum and a maximum value of each H,S,V values. So we create slider bars for minimum and maximum Hue , minimum and maximum Saturation and minimum and maximum Value.+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 **"namedWindow"** to display the slider bars. Each slider bar is created using the command **"cvCreateTrackbar"** . The first argument is the name of the slider bar , the second argument is where it will be displayed (put the same name as the window that you opened using the **namedWindow** ).The third argument is the value that this track bar will store , and the fourth argument is the maximum value that can be assigned.  We need to create six of these sliders, because our threshold will be made between a minimum and a maximum value of each H,S,V values. So we create slider bars for minimum and maximum Hue , minimum and maximum Saturation and minimum and maximum Value.
  
  
Line 218: 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 object more visible+ //dilate with 8x8 size element to make the threshold object more visible
    
  Mat erodeElement = getStructuringElement(MORPH_RECT, Size(3, 3));   Mat erodeElement = getStructuringElement(MORPH_RECT, Size(3, 3));
Line 327: Line 327:
  
  Finally , we show the original image , thresholded image and HSV image in three different windows using **"imshow"** . We update the key value whenever any key is pressed.  Finally , we show the original image , thresholded image and HSV image in three different windows using **"imshow"** . We update the key value whenever any key is pressed.
 +\\
 +\\
 +Below is a video demonstrating the program in real time.
 +{{youtube>UXVKAUHEVjI?medium}}
opencv_tutorials_t5.txt · Last modified: 2017/05/13 17:44 by acater