Crop features detected in OpenCV - python

I am trying to crop out features from a photo using opencv and haven't quite been able to find anything that helps to do so. I have photos in which I am trying to crop out rivets from metal panels to create a dataset of rivets that focus in on just the rivets. I have been able to use feature detection and feature matching using Orb to match features but I am unsure of how to then crop out those features. Ideally each photo should provide me with multiple cropped out photos of the rivets. Does anyone have any experience with anything such as this?

For template matching with OpenCV, you can use template matching (which is nicely described here)
If your template is skewed, rotated, etc. in the photo, you can use feature homography
For cropping the part of the image, you can look at this previously answered question.

Related

Why does OpenCV Stitcher Class fail for image sub sections?

I am trying to stitch panoramas using the OpenCV Stitcher Class in Python. The input data consists of partly overlapping images, but sometimes also images showing a sub section of another image, e.g.:
Whenever there are images showing a sub section, the stitching either fails ("Need more images" or "Camera parameters adjusting failed.") or leaves out the image showing the subsection. This also applies to images that are overlapping almost completely (>~90%).
There are sufficient features and matches found. The homography gets estimated correctly; see this output from the cv.draw_matches() function:
I have tried different feature detection methods (ORB, AKAZE, SIFT, SURF) as well as tuning various other parameters like bundle adjustment, warp type and confidence (conf_thresh).
It is essential for my application, that all images are included in the panorama, even when they show an area already covered by previous images.
What am I doing wrong? Are there any other methods for generating image stitchings using opencv-python?
Are there any other methods for generating image stitchings using
opencv-python?
The stitching package uses opencv-python and offers a lot of insight possibilities into the stitching process using the tutorial

How to implement object-detection in OpenCV? (Cognex VisionPro like object detection)

I have worked on some project which use computer vision software like Cognex's VisionPro. I am really impressing the way how Cognex's VisionPro detecting an object on image.
Let me descript about how it work.
First, the master image is needed to be trained. In that training process VisionPro will extract some features of the train image.
Second, Every time we want to detect that object in another query image, query image features will be extracted, and compare with the features of the train image to get it's location and rotated angle.
My question
Can we implement this method on opencv? Which algorithms could work in this case?
What I have done
I did some research and I know that we have keypoints detection methods like SIFT, SURF, or ORB and there is FLANN for keypoints matching. I have tried to run some example (most on opencv official tutorial), but the result it's not really as good as I want (it's to bad). The keypoints matching not really match on rotated object and it's really hard to get the rotated angle on query image.
This image below can better help you understand Cognex VisionPro's object dection.

Image segmentation python opencv

I want to ask for some advice about the procedure that I should implement for image segmentation working with opencv in python.
I have this kind of image and my purpose is to detect the white fiber like here
Does anyone have a proposition of the steps of image processing that I should do?
Since I can notice that object's color is different than the background, I found this guide helpful. The concept is the following :
1.apply RGB filters to your image,
2.grab contours using OpenCV, then
3.apply some handcraft conditions to them so as to fit your desired output, and finally
4.produce the box.
If all of your images share the same color patterns, this should work.. If not, it will prove noisy ..

stitching low feature images together

Is there a way to attach low feature images together from vertical? I have tried OpenCV's ORB, SIFT& SURF, however, if the images have no features or low features, it fails to stitch them together.
I want these images put together:
Please, let me know if there a way to stitch them together or if blending works?
the feature matching are often based on contours inside images, there is not contours on your both images like corners or particular poylgon. Once openCv can't find contours and so feature, it can't make template matching to check if feature are ok and assembly both images.
If you have some feature despite the image content, try to lower the matching threshold, it will allow algorithm to match feature that are not exactly the same, like in your two differents pictures

How can I use PIL to crop a select area based on face detection?

Hi I am wanting to use the python imaging library to crop images to a specific size for a website. I have a problem, these images are meant to show people's faces so I need to automatically crop based on them.
I know face detection is a difficult concept so I'm thinking of using the face.com API http://developers.face.com/tools/#faces/detect which is fine for what I want to do.
I'm just a little stuck on how I would use this data to crop a select area based on the majority of faces.
Can anybody help?
Joe
There is a library for python that have a concept of smart-cropping that among other options, can use face detection to do a smarter cropping.
It uses opencv under the hood, but you are isolated from it.
https://github.com/globocom/thumbor
If you have some rectangle that you want to excise from an image, here's what I might try first:
(optional) If the image is large, do a rough square crop centered on the face with dimensions sqrt(2) larger than the longer edge (if rectangular). Worst-case (45° rotation), it will still grab everything important.
Rotate based on the face orientation (something like rough_crop.rotate(math.degrees(math.atan(ydiff/xdiff)), trig is fun)
Do a final crop. If you did the initial crop, the face should be centered, otherwise you'll have to transform (rotate) all your old coordinates to the new image (more trig!).

Categories