2D Shape Detection
Hi, I am pretty new to the OpenCV world. I have a school assignment which require me to write a C++ code about 2d shape detection using Fourier Descriptors. The objective of this assignment is to detect the digit “6” in the provided image “a2.bmp” using C++ objective of this assignment is to detect the digit “6” in the provided image “a2.bmp” using C++. 1. Crop out the digit “6” from the top left corner of the image “ a2.bmp”, and store it as template. 2. Detect all the digit “6” in the image “ a2.bmp” by using Fourier Descriptors. I understand the concept for Fourier Descriptors in theory and did all tutorial for opencv. But I still have no idea how to write the source code, maybe so guidance or template for me will help me. Thanks.
show us, what you tried so far
Thanks Berak. I have now tried (1) Convert my input image to grey scale (2) Use Canny edge detection to Blur the image, perform thresholding and detect the edge Now I am stuck at how to list the contour in term of pixels and aIso how can I perform differential coding (current coordinate - next coordinate) for contour coordinates and save it as vector of new points. Convert this to two planes (one for x and another for y).
ok. after (1) and (2) use findContours(), to get the points, and boundingRect() to get the enclosing box. this will let you crop your template shape, and you can imsave() it.
(the advanced part is ofc. the fourier descriptors..)
Alright thanks Berak. After this step I will be preforming DFT. How do I calculate Magnitude from result of DFT and trim the high frequency components.
assuming, your dft has real output, you have to split it into x and y components, and use magnitude
hmmm... How about how do I trim the high frequency components after I got the magnitude.