Can anyone tell me of a method to refine disparity maps? I am trying to generate the disparity map of a face but the features like eyes, nose ,lips etc are not clear.How can I refine it to make it look better?
Take a look at
https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/cpp/stereo_match.cpp
there are some bm.state parameters (about line 197 - 207) that can be tweaked, we connected those values to some sliders so we could look at the result at the same time as we tweaked the values. you can also try with some different values for "blocksize". you can also try with some different distances between your cameras, if the cameras are too far apart, you will get poor / no results on close distances.
I assume that your code is similar to the example above.
Use stereoSGBM I am using it and you can use trackbars to tweak the parameters study the refernece of opencv and then manipulate each parameter based on the effect it has on your image eg:P1 P2 make it smoother etc
Related
I have a project, that aims for detecting distance to particular object(e.g traffic signs).
I have calivrated stereo-rig, and first thing I did was to find disparity image and then depth. However, since I need only distance to particular objects in the scene, I thought, that calculating disparity map is pretty long and heavy task, so I switched to feature detection method.
The idea here is following: I find similar features on both images, and then find disparity(just substract one feature point from another matched) only in the bboxes specified(i have attached the image).
The feature detector works correctly, however when I convert this disparities to actual depth, I have bad results, with a huge error. I convert them with following formula:
disparity = feature_matched1.x - feature_matched2.x
depth = baseline * focal / disparity.
The caluibration parameters seems to be correct and not the issue.
I want to ask, if I do this thing properly and is is possible to find depth? Maybe I have discoreved some false assumptions and I can not find depth like this method.
I can provide code, if it is necessary, however, I think it is more approach-related question.
When camera is moving forward/backward, I think stereo rectification would not work. I guess I have to search along the epipolar line directly. Currently, my only clue is to use LineIterator to iterate through epipolar line, and use its neighbors as descriptor. This is very unintelligent method. So I want to know if there is other ways, or helpful opencv functions.
Old problem - Mark Pollefeys had a nice solution for it about 18 years ago. The idea is to rectify in polar coordinates.
See his short paper and lecture notes, and look around for tech reports from there.
You could try with Scale Invariant Feature Transform (SIFT) maybe with this descriptor you could get the key-points and stabilize the image with some transformation function per frame.
SIFT in Matlab
I have two set of corresponding matches that I want to compute Homography Matrix between them. However, I found that the transformation between this points can not be modeled using just the Homography Matrix. I figured this by observing some lines in the original set of points have not represented as lines in the second set.
For example:
The previous state is very extreme in real the distortion is much less than that. It is usually a distortion because of the first set of points were extracted from image that was taken by scanner where the other set of points were extracted from a photo taken by mobile phone.
The Question:
How can I expand or Generalize the Homography matrix to make it includes this case? Or in other words, I want a non-line-preserve transformation model to use it instead of the Homography Matrix, Any Suggestion?
P.S OpenCV library is prefered if there is something ready to use.
EDIT:
Eliminating the distortion may not be an option for me because the photos are somewhat complex and I do not have the same Camera always plus I supposed to deal with images from unknown source (back-end separated from front-end). However, I have a reference which is planner and a query which has perspective + distoration effect which I want to correct it after I could found the corresponding pair matches.
It would be better if you had provided some examples of your images, so that we can understand your case better. From the description it seems that you are dealing with camera distortion.
Typical approach is to perform camera calibration once, then undistort each frame and finally work with images where straight lines look straight. All of these tasks are possible with OpenCV, consider the link above.
In case you cannot perform camera calibration to estimate distortion - there isn't much you can do. Try to calculate and apply homography on unrectified images - if the cameras don't have wide angle lens this should look ok (consider this case for example)
I want to find curvature at depth map
Look at the picture
This is example of curvature
Maybe if i represent image as function and take second derivative from it a can find curvatures. But i couldn't to implement it. (I tryed sobel operator from opencv)
Is there way out?
PS Sorry for my writing mistakes. English in not my native language.
That is not a depth map, it is a point cloud (but I assume it is generated from one single depth map z = f(x,y).
What curvature do you want to estimate? Mean, Gaussian, the whole 2nd fundamental form?
See, e.g. here for definitions. Here's a recent reference on fast estimation methods:
i need to find a marker like the ones used in Augmented Reality.
Like this:
I have a solid background on algebra and calculus, but no experience whatsoever on image processing. My thing is Php, sql and stuff.
I just want this to work, i've read the theory behind this and it's extremely hard to see in code for me.
The main idea is to do this as a batch process, so no interactivity is needed. What do you suggest?
Input : The sample image.
Output: Coordinates and normal vector in 3D of the marker.
The use for this will be linking images that have the same marker to spatialize them, a primitive version of photosync we could say. Just a caroussel of pinned images, the marker acting like the pin.
The reps given allowed me to post images, thanks.
You can always look at the open source libraries such as ARToolkit and see how it works but generally in order to get the 3D coordinates of marker you would need to:
Do the camera calibration.
Find marker in image using local features for example.
Using calibrated camera parameters and 2D coordinates of marker do the approximation the 3D coordinates.
I've never implemented sth similar by myself but I think this is a general concept you should apply on your method.
Your problem can be solved by perspective n point camera pose estimation. When you can reasonably assume that all correspondences are correct, a linear algorithm should do.
Since the marker is planar, you can also recover the displacement from the homography between the model plane and the image plane (link). As usual, best results are obtained by iterative algorithms (link).