drexel_darwin_opencv
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
drexel_darwin_opencv [2016/11/06 04:48] – [Real Time Trial On Ladder(2)] dwallace | drexel_darwin_opencv [2016/11/06 19:20] (current) – dwallace | ||
---|---|---|---|
Line 13: | Line 13: | ||
I will be using Visual Cpp 2010 Express as my platform for practicing OpenCV. | I will be using Visual Cpp 2010 Express as my platform for practicing OpenCV. | ||
- | I refer to [[https:// | + | I refer to [[https:// |
There were some error with using OpenCV2.1 and OpenCV2.2 in this case. | There were some error with using OpenCV2.1 and OpenCV2.2 in this case. | ||
- | * [[http:// | + | * [[http:// |
* [[http:// | * [[http:// | ||
- | I have changed to use OpenCV2.4.3 instead. I followed the tutorial [[http:// | + | I have changed to use OpenCV2.4.3 instead. I followed the tutorial [[http:// |
{{dylanw: | {{dylanw: | ||
Line 27: | Line 27: | ||
I have also prepared a MS Power Point presentation for a step by step installation of OpenCV. | I have also prepared a MS Power Point presentation for a step by step installation of OpenCV. | ||
- | {{dylanw:OpenCV_Tutorial.pptx}}\\ | + | {{dylanw:opencv_tutorial.pptx}}\\ |
==== Rectangle Recognition Code ==== | ==== Rectangle Recognition Code ==== | ||
Line 46: | Line 46: | ||
while(1){ | while(1){ | ||
cap >> original; | cap >> original; | ||
- | </ | + | |
- | < | + | |
Mat original, pyr, timg, gray;// | Mat original, pyr, timg, gray;// | ||
... | ... | ||
Line 82: | Line 81: | ||
//using the kernel of default aperture size of 3 as defined by " | //using the kernel of default aperture size of 3 as defined by " | ||
//at default start point specified by " | //at default start point specified by " | ||
- | </ | + | |
- | < | + | |
vector< | vector< | ||
// | // | ||
Line 93: | Line 91: | ||
//processed image is saved to contours | //processed image is saved to contours | ||
//in the designated mode | //in the designated mode | ||
- | </syntaxhighlight> | + | </code> |
- | ''' | + | **Note***: Input image to **findContours** function must be a single channel image. It need not be grayscale. |
- | <syntaxhighlight lang=" | + | |
+ | <code c++> | ||
for( size_t i = 0; i < contours.size(); | for( size_t i = 0; i < contours.size(); | ||
{ | { | ||
Line 138: | Line 137: | ||
Here is a sample run of my code to filter out black rectangles and output the X and Y coordinates of the centers of the squares in the output MS-Prompt window. | Here is a sample run of my code to filter out black rectangles and output the X and Y coordinates of the centers of the squares in the output MS-Prompt window. | ||
- | {{dylanw:squaresCoordinates.jpg}}\\ | + | {{dylanw:squarescoordinates.jpg}}\\ |
Some food for thought: | Some food for thought: | ||
Line 152: | Line 151: | ||
[[https:// | [[https:// | ||
- | {{#ev:youtube|R0gCfSxRoOk}}\\ | + | {{youtube>R0gCfSxRoOk?large}}\\ |
Video explanation: | Video explanation: | ||
Line 174: | Line 173: | ||
However, as can be seen circled in red, when there is a smooth straight line, the points do not appear, and hence on the ladder rungs which has pretty smooth horizontal edge features, points are hard to come by and a rectangle is hard to detect. | However, as can be seen circled in red, when there is a smooth straight line, the points do not appear, and hence on the ladder rungs which has pretty smooth horizontal edge features, points are hard to come by and a rectangle is hard to detect. | ||
- | {{dylanw:contourPointsLadder.jpg}}\\ | + | {{dylanw:contourpointsladder.jpg}}\\ |
This means that one of the adjustments I made during my previous trial run, which was intended to smoothen the sides of the spaces in between ladder rungs by covering up the sides, should make the ladder rungs more difficult to be detected. However the opposite occur. | This means that one of the adjustments I made during my previous trial run, which was intended to smoothen the sides of the spaces in between ladder rungs by covering up the sides, should make the ladder rungs more difficult to be detected. However the opposite occur. | ||
Line 186: | Line 185: | ||
(I made the left cover slanted to achieve more points along vertical and prove my point) | (I made the left cover slanted to achieve more points along vertical and prove my point) | ||
- | {{dylanw:contourPointsCoveredLadder.jpg}}\\ | + | {{dylanw:contourpointscoveredladder.jpg}}\\ |
When the ladder is tilted. the detection of rectangles improved greatly (detecting the ladder rungs instead of the spaces in between ladder rungs now by using black colored covers). | When the ladder is tilted. the detection of rectangles improved greatly (detecting the ladder rungs instead of the spaces in between ladder rungs now by using black colored covers). | ||
Line 194: | Line 193: | ||
Below is a picture of it. | Below is a picture of it. | ||
- | {{dylanw:contourPointsTiltedLadder.jpg}}\\ | + | {{dylanw:contourpointstiltedladder.jpg}}\\ |
This algorithm which uses contour points and the **approxPolyDP()** function is not effective to detect lines which are perfectly vertical or horizontal to the camera, like the ladder rungs. | This algorithm which uses contour points and the **approxPolyDP()** function is not effective to detect lines which are perfectly vertical or horizontal to the camera, like the ladder rungs. | ||
Line 216: | Line 215: | ||
Here are some pictures. | Here are some pictures. | ||
- | {{dylanw:ladderRungCanny.jpg}}\\ | + | {{dylanw:ladderrungcanny.jpg}}\\ |
- | {{dylanw:ladderRungSpaceCanny.jpg}}\\ | + | {{dylanw:ladderrungspacecanny.jpg}}\\ |
drexel_darwin_opencv.1478436484.txt.gz · Last modified: by dwallace