I am currently using OpenCV in Java, but if need be I can switch to something else.
I have a set of known points in world coordinates as well as known in image coordinates. These points are not obtained with a calibration target. They are probably quite inaccurate. I can assume that they are close to coplanar.
I am trying to obtain a homography and lens correction from this. The camera is cheap(ish) and so there are lens issues.
I have been struggling to get the OpenCV functions to help me here without a calibration target. There are a lot of similar questions asked (the most similar I found was this one: Correct lens distortion using single calibration image in Matlab), but none quite fit the bill.
I was thinking I could iteratively find the homography, correct, find the lens distortion, correct and repeat until I got an OK result. Even so, I can't seem to do these separately in OpenCV.
I am quite new to OpenCV, so please be gentle.
openCV have this functionality
Camera calibration
Function "calibrateCamera" take as input world coordinates and corresponding image coordinates, and return camera intrinsic (also distortion)
At a minimum you need to "see" features that are known to be collinear, regardless of whether they are the images of coplanar points. That is because the error signal that you need to minimize in order to estimate (and remove) the lens's radial distortion is, by definition, the deviation of collinear points from straight lines.
See also this answer.
Related
I need to detect shapes and their colours on a taken image. These shapes are: a heart, a rectangle, a star and a circle. Each shape has one of 5 predefined colours. Colour recognition works fine, but shape recognition is a real problem.
After hours and hours of googling, trying and tweaking code, the best I have come up with is the following procedure:
First, read the image and convert it to grayscale.
Then, apply blur to reduce the noise from the background.
Medianblur seems to work best here. Normal blur has little effect, and Gaussian blur rounds the edges of the shapes which gives trouble.
Next, apply threshhold.
AdaptiveThreshold doesn't give the results I expected; the result vary widely with each image. I now apply two thresholds: One uses Otsu's algorithm to filter the light shapes, and the other uses the Binary Inverted value for the darker shapes.
Finally, find contours on the two threshholds and merge them in one list.
By the amount of points found in each contour, I decide which shape is found.
I have tried adding Canny, sharpening the image, different threshholds, Convex Hull, Houghes, etc. I probably tried every possible value for each method as well. For now, I can get things working with the above procedure on a few images, but then it fails again on a new image. Either it detects too much points in a contour, or it doesn't detect the shape at all.
I am really stuck and dont know what else to try. One thing I still have to work out is using masks, but I can't find much information on that and don't know if it would make any difference at all.
Any advice is more than welcome. If you would like to see my code, please ask. You can find sample images here: http://tinypic.com/a/34tbr/1
I want to detect a circle, rectangle shaped object in an image and read the information from that object. Is there any api in java which will be helpful to me?
Ex: Detect a round shaped coin in a white background and obtain information about that that coin like ( value of a coin, etc.)
Thanks.
Here's an answer to a similar question for C++.
For Java, you can use the OpenCV wrappers. However, once you understand the essence of the approach you should be able to solve your problem using whichever framework is available.
Circles are perfect targets for the Hough transform. Check this out Detect circles with HT and OpenCV
Rectangles are a bit harder since the Hough Transform is not rotation invariant. You can go into edge detection and fast fitting (Fast line and rectangle detection by clustering and grouping)
I am constantly getting frames of an eye from a webcam. I need to detect where the pupil relative to its previous position using Object Tracking with OpenCv for Android.
So far I haven't been able to find any useful pointers as to how to go about it. Are there any links/tutorials that can help?
I have already used detection algorithms like Contour Detection, Hough Circles etc, which sometimes yield false positives so I wanted something more robust.
Anyway, I can suggest you try implement ideas from paper:
Accurate Eye Center Location and Tracking Using Isophote Curvature
I have used this method, it gives good results, fast and simple.
I would like to detect ellipses with OpenCV for Android, using the Tutorial 2-Basic included with OpenCV 2.4.1 package as a starting point. Note that my ellipse would be a perfect-photoshop one.
From what I understand, using the "HoughCircles" will only find perfect (or so) circles, thus leaving ellipses out.
Any help would be much appreciated as I am a total beginner at OpenCV
This is what I've tried so far
case Sample2NativeCamera.VIEW_MODE_CANNY: (ignore the Canny mode...)
capture.retrieve(mGray, Highgui.CV_CAP_ANDROID_GREY_FRAME);
Imgproc.HoughCircles(mGray, mCircles, Imgproc.CV_HOUGH_GRADIENT, 1, 20);
Log.d("Ellipse Points", " X " + mCircles.get(1,1)[0] + mCircles.get(1, 1)[1]);
break;
If you think any more info could be useful, please let me know.
One possible solution to your problem is similar to this thread Detection of coins (and fit ellipses) on an image .
You should take a look a opencv's function fitEllipse.
The parameters used in HoughCircles play a fundamental role. HoughCircles will detect not just perfect, but also near-perfect circles (ellipses). I suggest you check this examples:
How to detect circles (coins) in a photo
Simple object detection using OpenCV
OpenCV dot target detection
Reshaping noisy coin into a circle form
And this answer has a decent collection of references.
If you already have an idea of the sizes of the ellipses that you're looking for, then try the following steps:
Find Canny edges in the image
Use a sliding window, the size of which is the maximum length of the major axis of ellipses you're looking for.
Within the window, collect all edge pixels, pick 6 pixels randomly and use linear least squares to fit an ellipse in the general form.
Repeat the above step in a RANSAC like procedure.
If there are enough inliers, you have an ellipse.
I want to detect a circle, rectangle shaped object in an image and read the information from that object. Is there any api in java which will be helpful to me?
Ex: Detect a round shaped coin in a white background and obtain information about that that coin like ( value of a coin, etc.)
Thanks.
Here's an answer to a similar question for C++.
For Java, you can use the OpenCV wrappers. However, once you understand the essence of the approach you should be able to solve your problem using whichever framework is available.
Circles are perfect targets for the Hough transform. Check this out Detect circles with HT and OpenCV
Rectangles are a bit harder since the Hough Transform is not rotation invariant. You can go into edge detection and fast fitting (Fast line and rectangle detection by clustering and grouping)