Wrong rectification in MATLAB - matlab

The rectification function in Matlab seems to be responding wrong. Can anyone let me know if I am getting the right output?
Left Image
Right Image
Anaglyph of unrectified images
Anaglyph of rectified images
Here is my code:
leftImageSnapshot = getsnapshot(handles.vidL);
imshow(leftImageSnapshot);
rightImageSnapshot = getsnapshot(handles.vidR);
imshow(rightImageSnapshot);
[I1Rect,I2Rect]=rectifyStereoImages(I1,I2,stereoParams,'OutputView','valid');
imshowpair(I1Rect,I2Rect,'falsecolor','ColorChannels','red-cyan');
I was following this link for image rectification. After rectification, the images are supposed to look like the cameras are parallel. But in my case, the vertical disparity still exists in the image.
I am trying to obtain a disparity map for which the vertical disparity should be removed.

My best guess would be that your cameras were moved after you did the calibration. Once you calibrate, the position and orientation of the cameras relative to each other cannot change. If it does, your stereoParams are no longer valid.
To see what went wrong, do the calibration again using the Stereo Camera Calibrator app, and then click "Show Rectified" button at the lower left corner of the main image pane. I will show you a rectified pair of calibration images. If those look ok, then your cameras have moved and you have to take the calibration images again and recalibrate. If the rectified calibration images look bad, then something is wrong with your calibration.
By the way, there is a stereoAnaglyph function, which you can use to create a red-cyan anaglyph.

Related

Camera Calibrator Matlab

I'm using the camera corrector application to correct a series of images that have barrel distortion using chessboards.
Following the steps below:
1.I attach the series of photos to be corrected with the different positions of the chessboard, without modifying the position of the camera.
I introduce the size of the different squares that make up the board. And frame that has a high distortion the image to process
enter image description here
I perform the processing of the different photos and press the calibration button
enter image description here
Detect the different points of the chessboard
enter image description here
And I hit the "show undistorted" button. To see the result of the correction.
enter image description here
Apparently the image is corrected. But using a photo correction program, I observed that this is not the case, that there are errors in its correction.
enter image description here
it is observed that the upper right corner is not fully corrected. I have carried out the same procedure with a smaller number of photos, with a different location of the chessboard, etc. I am somewhat confused. What could I do to completely correct the image?
enter image description here

Is it possible to create a 3D photo from a normal photo?

If I have understand well, 3D 360 photos are created from a panorama photo, so I guess it should be possible to create a 3D photo (non 360) from a normal photo. But how? I did not find anything in Google! Any idea of what should I search??
So far, if nothing available (I don't think so), I'll try to duplicate the same photo in each eye. One of the pictures a little bit moved to the right, and the other one moved a little bit to the left. But I think the distortion algorithm is much more complicated.
Note: I'm also receiving answers here: https://plus.google.com/u/0/115463690952639951338/posts/4KdqFcqUTT9
I am in no way certain of this, but my intuition on how 3D 360 images are created in GoogleVR is this:
As you take a panorama image, it actually takes a series of images. As you turn the phone around, the perspective changes slightly with each image, not only by angle, but also offset (except in the unlikely event you spin the phone around its own axis). When it stitches together the final image, it creates one image for each eye, picking suitable images from the series so that it creates a 3D effect when viewed together. The same "area" of the image for each eye comes from a different source image.
You can't do anything similar with a single image. It's the multitude of images produced, each with a different perspective coming from the turning of the phone, that enables the algorithm to create a 3D image.
2D lacks a dimension hence cannot be converted to 3D just like that, but there are clever ways for example Google Pixel even though doesn't have 2 camera can make it seem like the image is 3D by applying some Machine learning algorithm that create the effect of perspective and depth by selective blurring.
3d photos can't be taken by normal but you can take 360 photos with normal camera ..... There are many apps via which you can do this ..... Also there are many algorithms to do it programmatically

Problems with single camera calibration using MATLAB Camera Calibrator

I'm doing a project that requires acquiring real world coordination from a camera. The first thing that I need to do is calibrate my camera. I use Camera Calibrator from MATLAB Toolbox, and about 40 samples for calibrating. All the samples was taken by Logitech C922. But after calibrate, the result seems so wrong, as you can see in the image below.
It is more distortion than the original image. I have also tried to calibrate using OpenCV but the result is the same. Anyone know what wrong and why does this happen ?
I am sorry if those questions are really beginner level, camera calibration is very new to me and I was not able to find my answers.
Thank you in advance!
Firstly, you really need to figure out what does 'calibration' means.
it's clear that the picture is showing the undistorted picture,since the lines on the chessboard and those on the background are quite straight. Without undistortion the chessboard in the center would look like squeezed in radial directions. Check the button 'show original' on the bottom-left corner of your picture, click it, and find the difference between these two pics.
What this calibrator does is that it calculates the intrinsic/extrinsic parameters, distortion coefficients and, if you wish, undistort the pictures you gave to her. She already did the job.

Matlab camera calibration getting peripheral corners

I don't know why, but Matlab Camera Calibration app is getting also the peripheral corners, it is not supposed to do that. Any clues?
By the way, the border squares are more thinner by purpose, just to try to make Matlab ignore them, I also used normal squares side on the borders but I got the same Matlab behavior.
My image result:
Correct result from matlab website:
The thing is that Matlab usually can't handle a "perfect" image. Since I was analyzing my patter before printing and not an actual photo of it, it seems the corner detection get lost. I just added some blur to my pattern and Matlab was able to detect it correctly. Another "solution" is to reduce the borders size, since there is no need to them to have the full rectangle size.
Perfect image
Perfect image + blur - OK
Perfect image with 40% borders - OK
Original perfect image with 40% borders

Shape Detection (circle, square, rectangle, triangle, ellipse) for a camera captured image + i OS 5 + Open CV

I am new to OpenCV and need to know the method of OpenCV which detects different shapes (circle, square, rectangle, triangle, ellipse) in a camera captured image for iPhone.
so, could someone directs me to the right direction (references/articles/anything) that which techniques are better to get it done.
Thanks..
iOmi
First you will probably need to look at an edge detector such as Canny to extract the shapes into a binary image. (Although this may be expensive for the iphone)
For circles I would have a look at the HoughCircles.
For squares and rectangles you should look at the findContours method and the sample code squares.cpp in the samples directory when you downloaded opencv.
With a quick google search I was able to find an article about detecting shapes in C# which roughly corresponds to the methods you would use in another language while using the opencv library.
I have not used opencv in ios but I hope this will help get you started.