How to solve this? (finding an image)
Edited, Thank you for bearing with me.
Ok! I will approach my question in a different manner this time:
Using
- Python 3.8.3 64-bit
- opencv-python 4.3.0.36
- VS Code
So I have this image:
How would you match the paint palette on the top (green box) with the one within the image (red box)?
matchtemplate does not work since there is rotation and different image size.
I am a beginner and I am trying to learn through projects I make up myself. I have been trying to figure this out for quite a while with no success, I hope you guys can help me. Thanks!
no, won't work. feature detection works on texture, not shape.
it's also not meant to find "a needle in a haystack", but "a rotated / scaled part of the same image"
features2D
is already on OpenCV, you should have it installed. Without any other information is difficult give an help. It's up to the version of OpenCV that you're using, in the version that I use daily, some algorithm like SIFT are in thexfeatures2d
module. Despite the characteristics of the feature detector that can deal with scale and rotation or not, the problem here is that you want to recognize two SIMILAR objects that have the same shape. In that case I think is might be better address the problem as a object detection. So you're able to find eventually the two object (or whatever) in different color and then you can try to compute an homography. It is an idea, but I think you should study and think about many stuff...Thank you for your answers! I am a beginner, these terms may get confusing:
using:
python 3.8.3 64bit opencv 4.3.0.36
The problem I have with module features2d and xfeatures2d is that VS Code does not recognize them, VS Code does offer the autocomplete option, but when I hover the mouse on it, the description reads "unknown".
When I try to run the code in: https://docs.opencv.org/master/d5/d6f... , the following error appears:
cv2.error: OpenCV(4.3.0) C:\projects\opencv-python\opencv_contrib\modules\xfeatures2d\src\surf.cpp:1029: error: (-213:The function/feature is not implemented) This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'cv::xfeatures2d::SURF::create'
The error is very explanatory, it say that you should recompile the entire library with the
nonfree
module. In opencv 3 it was necessary to download the opencv_contrib and build against it. You find a lot of howto guide about it, is really simple. In Opencv 4 I don't know exactly how have been moved that package. Regarding the problem, The ingredients for the recipe are the following:That's the easy way that I suggest to you as a beginner, Try with that first before deep into other techniques. The first two step should be executed in green and the other img. If the input image (the green) is always in BW and the others are coloured, I suggest you to convert the image to grayscale
@HYPEREGO, thank you!
I cannot find any guide on installing the
nonfree
modules in Visual Studio Code. Do you know if it is possible, or if I must use Visual Studio Community?