say we got a 8x9 chessboard, and the function cv::findChessboardCorners recognize it without problem, My question is why does the function not recognize in the same image a a chessboard with smaller size, I tried in a for-loop and decremented the size the function may recognize a chessboard of let say 5x4 and 4x5 but not 6x7 for example ?
any idea why is that happening ?
I already tried debugging the program and I didn't understand what really happens in calibinit.hpp
thanks in advance !
I think the main problem is that you would have ambiguities since it is easily possible to find different smaller chessboards in a larger one.
If you do corner detection on an image consisting of a chessboard, you will find a regular grid of corners.
Then findChessboardCorners needs to find a structur which is very similar to the given chessboard of size (x,y). It will rate the different possibilities to map the chessboard to the regular grid found by the corner detection and these ratings are very similar.
So it is difficult to decide which is THE CHESSBOARD, you are looking for.
It because the recognized board must have light border.
Related
I have 2 images of the same scene but with slightly difference. It is due to the fact that I have taken the picture with 2 different equipment, and one is not perfectly right.
That create a little parallax problem somewhere on the photo. It is really slight when you compare the 2 photos, but just enough disturbing for what I want to do with those images.
My question is : what would be the best algorithm to minimize the created error?
What I was thinking was :
pick X points in the first image, pick their correspondance points in the other image, then create a function that project the first points to the other and then apply this function to all the points in the scene.
Something like that :
(Red point are picked points, and other colors are the deformation of each points in the scene (probably not correct since I did it fastly).
Would it be a good way to proceed? If yes, what would be a good interpolation algorithm using the points.
If no, is there any other algorithm that I could use in order the minimize the error?
Thanks a lot!
Yes, using 4 pairs of points you can calculate matrix of perspective transformation and later apply this transformation to the whole image.
OpenCV library contains getPerspectiveTransform function for this case (also findHomography). You can also apply warpPerspective to correct image.
Example
I have tried to use edge detection to find the contour of images and try to compare the similarity of the contours by matchshape function. However, results are not as good as expected. I think it may be because of the images are not aligned before calculating the similarity. Therefore, I am asking for a way of aligning two contours in opencv. I am thinking of aligning by first finding the smallest bounding box or circle and then find out translation, rotation or resize needed to align those boxes. Then apply those transformation on the contour and test the similarity of them. Does this method work? Is there any method to align images? Thanks for your help. For your reference, attached are two contours going to be tested. They should be very similar but the distance found is quite large. The first two images have larger distance than that between the first and the last one, which seems contradicts with what it looks like (the last one should be the worst). Thanks.
These kinds of problems are known as registration problems. CPD, BCPD, and ICP would be your best shot.
[https://github.com/neka-nat/probreg][1]
I'm trying to track little white dots on edges table. In most of case it works. I'm using cornerHarris function like it's used in this tutorial : http://docs.opencv.org/doc/tutorials/features2d/trackingmotion/harris_detector/harris_detector.html .
Sometimes, I have got a problem : reflection of the light on edges creates point of interest which I have to not consider.
For example :
I'm searching to the two nearest points of the top corners, as you can see on the right edges, i have find dots(red and green dots) and on the left edges, light noise is a problem (cyan and blue dots).
Does someone knows a method to keep only dots white on my picture ? Thankyou and sorry for my english
On the purely image processing part, I would recommend using some kind of shape feature analysis(like comparing the histogram in say 8x8 around your currently examined point of interest to precomputed ones of the features you want .
This would mean that you first look for points with Harris corners, then compare the features to dismiss unwanted ones ( euclidian distance in the 8x8 = 64D ?). This of course assumes the existence of a strong feature (read "taking time to find a good one")
It also assumes you already know what your feature points look like beforehand.
Alternative more on the computer vision side : use geometry of your corner points repartition to your advantage : you probably want a distorted rectangle, so make sure you find one ! Surely you can compute a function that gives the validity of the last feature point assuming 3 others ? (Distance of intersection of the 2 lines generated by the other 3 points ...)
The typical and coolest approach would then apply RANSAC to it : try random (but not all !) combinations of your points and check which one fits best using that function, and consider those as good.
If you intend on tracking over time or over several images, you will have to tune it a bit, as ransac can occasionally fail (statistics of random combinations ...), and you would then use points from your previously successful run to guestimate the position.
Last idea for the moment : use some color-aware derivation technique : do you compute Harris corner of the rgb image or of a flattened version to gray ? Some gradients use color information as extra tip to discern edges, and I'm not sure the corners you're finding use any of those. Then again it might mean reimplementing Harris corners algorithm (try it, it's fun, and not that hard if you have a good algebra library to do the heavy work)
I recommend the geometric test of fitting as it uses wisely model-info of your system rather than assumptions on how reflections look like.
Really funny introduction to RANSAC : danielwedge.com/ransac/
Edit : Trusty photoshop knows what I mean : I highlighted the invalid shapes
Valid grid, photoshop says so
Invalid grid, logical, right ?
i am using open CV and C++. I used find Contours and moments to display the center coordinates of circles in an image. However,there is this strange coordinate which appears in between the good ones. It is [-2147483648,-2147483648]. Does anybody know what it means?
thanks
Chances that this reason occurs could due to the integer type used. Also known as an integer overflow.
This occurs when an arithmetic operation attempts to create a numeric value that is too large for the available storage space which you declared.
However, there may be other reasons as well. From what I noticed, the values are kind of big. May I ask what is the size of the image that you trying to implement the contours and moments on? Cuz I have done something similar myself, and the values are way too big.
If the size of the image you are processing is a not of humongous size(like really really big), then there might be something wrong with the code. Please edit the question to include the code, so that all the stackoverflow people can help you.
This are some links of how to find the centre of a circle, hope you find it useful. I used this links when I was doing a similar program back then.
How to find the coordinates of a point w.r.t another point on an image using OpenCV
http://lfhck.com/question/278176/python-and-opencv-how-do-i-detect-all-filledcirclesround-objects-in-an-image
Sorry it was not about the type that i used but it was the image quality which had problems. I had to blur that part so that it does not detect that color there.
I'm relatively new to OpenCV, and I'm working on a project where I need to count the number of objects on a grid. the grid is the background of the image, and there's either an object in each space or there isn't; I need to count the number present, and I don't really know where to start. I've searched here and other places, but can't seem to find what I'm looking for. I will need to be tracking the space numbers of the grid in the future, so I will also eventually need to know whether each grid space is occupied or empty. I'm not going so far as to ask for a coded example, but does anybody know of any source or tutorials to accomplish this task or one similar to it? Thanks for your help!
Further Details: images will come from a stable-mounted camera, objects are of relatively uniform shape, but varying size and color.
I would first answer a few questions:
Will an object be completely enclosed in a grid cell? Or can it be placed on top of a grid line? (In other words, will the object hide a line from the camera?)
Will more than one object be in one cell?
Can an object occupy more than one cell? (closely related to question 1)
Given reasonable answers to those questions, I believe the problem can be broken into two parts: first, identify the centers of each grid space. To count objects, you can then sample that region to see if anything "not background" is there.
You can then assume that a grid space is defined by four strong, regularly-placed, corner features. (For the sake of discussion, I'll assume you've performed the initial image preparation as needed: histogram equalization, gaussian blur for noise reduction, etc.) From there, you might try some of OpenCV's methods for finding corners (Harris corner detector, cvGoodFeaturesToTrack, etc). It's likely that you can borrow some of the techniques found in OpenCV's square finding example (samples/c/square.c). For this task, it's probably sufficient to assume that the grid center is just the centroid of each set of "adjacent" (or sufficiently near) corners.
Alternatively, you might use the Hough transform to identify the principal horizontal and vertical lines in the image. You can then determine the intersection points to identify the extents of each grid cell. This implementation might be more challenging since inferring structure (or adjacency) from "nearby" vertices in order to find a grid center seems more difficult.