Ask Your Question

rcarrasco's profile - activity

2015-02-02 02:00:57 -0500 commented question Stereo to point cloud

I can get the camera baseline and FOV, but I don't know how to compute x,y,z. Can you help me?

2015-01-30 07:56:43 -0500 asked a question Stereo to point cloud

Hi, I have a calibrated stereo camera with ROS package camera_calibration, and I would like convert images to point cloud.

I'm going to do this with opencv, with the function reprojectImageTo3D, but I need the Q matrix.

I found another function to calculate the Q matrix but I don't know some parameters:

My calibration data:

Right camera:

image_width: 640
image_height: 480
camera_name: 00b09d0100a8cd50
camera_matrix:
  rows: 3
  cols: 3
  data: [618.406355982753, 0, 328.938909311292, 0, 622.618018605044, 192.823847411511, 0, 0, 1]
distortion_model: plumb_bob
distortion_coefficients:
rows: 1
cols: 5
data: [-0.46935852500581, 0.495020825022316, 0.0069132704108347, 0.000957659601339344, 0]
rectification_matrix:
rows: 3
cols: 3
data: [0.987794979792204, 0.000360084570829607, -0.15575926372586, -0.00147162495744743, 0.999974269489065, -0.00702101700582399, 0.155752727800526, 0.00716454457124124, 0.987770093232116]
projection_matrix:
rows: 3
cols: 4
data: [2536.3424975867, 0, 419.49533700943, 112.802583009304, 0, 2536.3424975867, 207.939946174622, 0, 0, 0, 1, 0]

Left camera:

image_width: 640
image_height: 480
camera_name: 00b09d01009b8da3
camera_matrix:
  rows: 3
  cols: 3
  data: [1303.84092827502, 0, 305.740018425863, 0, 1314.11682894773, 177.738196152231, 0, 0, 1]
distortion_model: plumb_bob
distortion_coefficients:
   rows: 1
   cols: 5
   data: [-0.151635456291086, 0.3629641480367, -0.00784184518383463, -0.000413869770118943, 0]
rectification_matrix:
   rows: 3
   cols: 3
   data: [0.98618892981478, -0.00296598739861576, -0.165597698140795, 0.0041481493735406, 0.999968321024829, 0.006793364671487, 0.165572303141417, -0.0073864650230178, 0.986169991718928]
projection_matrix:
 rows: 3
 cols: 4
 data: [2536.3424975867, 0, 419.49533700943, 0, 0, 2536.3424975867, 207.939946174622, 0, 0, 0, 1, 0]

How I obtain the R and T?

stereoRectify(InputArray cameraMatrix1, => camera_matrix_left
              InputArray distCoeffs1, => distortion_coefficients_left
              InputArray cameraMatrix2, => camera_matrix_right
              InputArray distCoeffs2, => distortion_coefficients_right
              Size imageSize, => size of the images
              InputArray R, => ??????
              InputArray T => ??????
              OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q)
2015-01-19 05:31:21 -0500 asked a question stereoRectify doubt

Hi, I want to use the function stereoRectify to get the Q matrix, but I don't know all the input parameters. How can I calculate the R and T parameters?

This is my calibration data:

Right camera:
camera_matrix: [634.909677387927, 0, 297.560249240374, 0, 634.865463121865, 158.8371760664, 0, 0, 1]

distortion_coefficients: [-0.504454260664395, 0.138609530989189, 0.0203198092295076, 0.00967761579645135, 0]

rectification_matrix: [0.966163280084709, -0.0083550378707894, -0.257795868000506, 0.00163860823321609, 0.999653878808556, -0.0262571427627996, 0.257926018809686, 0.0249462607455643, 0.965842561132921]

projection_matrix:
data: [6304.94671586074, 0, 473.495297431946, 280.518391789843, 0, 6304.94671586074, 167.603784561157, 0, 0, 0, 1, 0]

Left camera:   
camera_matrix: [1356.35752938346, 0, 261.669289951563, 0, 1361.87246183291, 152.711809345378, 0, 0, 1]

distortion_coefficients: [-0.288103120402993, 0.398595604261962, -0.00473618587860346, -0.0097855325627947, 0]

rectification_matrix: [0.968033107464518, -0.00309525870864915, -0.250803353697904, 0.00962260176867882, 0.999646030047709, 0.0248036316908628, 0.250637803189764, -0.0264241174569953, 0.967720237273577]

projection_matrix:[6304.94671586074, 0, 473.495297431946, 0, 0, 6304.94671586074, 167.603784561157, 0, 0, 0, 1, 0]

Thanks.

2015-01-13 01:45:09 -0500 received badge  Enthusiast
2015-01-09 06:17:07 -0500 received badge  Editor (source)
2015-01-09 01:53:24 -0500 asked a question Get Q matrix.

Hi, I'm new in opencv and I want to get the XYZ of a pixel. I have a stereo camera calibrated and I read that to obtain 3D coordinates used reprojectImageTo3D function, but I'm not sure how to get the parameter Q and disparity.

reprojectImageTo3D(InputArray disparity, OutputArray _3dImage, InputArray Q, bool handleMissingValues=false, int ddepth=-1 )

To get Q matrix, should I use stereoRectify function or is there another method?

UPDATE:

I try the next code to get the Q matrix:

#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
 cv::Mat R1;
 cv::Mat R2;
 cv::Mat P1;
 cv::Mat P2;
 cv::Mat Q;
 CvSize imageSize;
 Rect* validPixROI1=0;
 Rect* validPixROI2=0;
 imageSize.width = 640;
 imageSize.height = 480;

 float cam_matR[9] = {680.6194505553137, 0.0, 355.46071062373017, 0.0, 708.4327407870684, 166.020861837664, 0.0, 0.0, 1.0};
 float cam_matL[9] = {1443.36997726192, 0.0, 310.098678757853, 0.0, 1526.48462097625, -31.0051090142091, 0.0, 0.0, 1.0};
 float dist_cefR[9] = {-0.539747915499244, 0.40294694145911397, -0.014712916213760259, -0.035996511261222594, 0.0}; 
 float dist_cefL[9] = {-0.219030634019159, 0.607086354732134, -0.0559437412413443, 0.0274216517856112, 0.0};
 float _R[9] = {4347.70749725124, 0.0, 559.7353515625,0.0, 4347.70749725124, 134.066455841064,0.0, 0.0, 1.0};
 float _T[3] = {0.0,0.0,0.0};

 const cv::Mat cameraMatrixR = cv::Mat(3,3,CV_64F,cam_matR);
 const cv::Mat cameraMatrixL = cv::Mat(3,3,CV_64F,cam_matL);

 const cv::Mat distCoeffR = cv::Mat(1,5,CV_64F,dist_cefR);
 const cv::Mat distCoeffL = cv::Mat(1,5,CV_64F,dist_cefL);

 const cv::Mat R = cv::Mat(3,3,CV_64F,_R);
 const cv::Mat T = cv::Mat(1,3,CV_64F,_T);

 stereoRectify(cameraMatrixR, distCoeffR, cameraMatrixL, distCoeffL, imageSize, R, T, R1, R2, P1, P2, Q, 0, -1, );
}

And I get the next error:

OpenCV Error: Assertion failed ((D.rows == ((flags & CV_GEMM_A_T) == 0 ? A.rows : A.cols)) && (D.cols == ((flags & CV_GEMM_B_T) == 0 ? B.cols : B.rows)) && D.type() == A.type()) in cvGEMM, file /tmp/buildd/ros-hydro-opencv2-2.4.9-2precise-20140819-1745/modules/core/src/matmul.cpp, line 3150
terminate called after throwing an instance of 'cv::Exception'
 what():  /tmp/buildd/ros-hydro-opencv2-2.4.9-2precise-20140819-1745/modules/core/src/matmul.cpp:3150: error: (-215) (D.rows == ((flags & CV_GEMM_A_T) == 0 ? A.rows : A.cols)) && (D.cols == ((flags & CV_GEMM_B_T) == 0 ? B.cols : B.rows)) && D.type() == A.type() in function cvGEMM

Aborted (core dumped)
2015-01-08 09:26:17 -0500 received badge  Critic (source)
2015-01-07 08:13:34 -0500 commented answer Real world coordinates from a pixel

OK. In my application the work piece is not always the same. So I need XYZ coord of the pixel.

2015-01-07 06:39:45 -0500 commented answer Real world coordinates from a pixel

Nice work!! But how do you determine the depth?

2015-01-07 05:52:41 -0500 commented answer Real world coordinates from a pixel

I have a work piece with holes and I want to determine where are the holes to move the robot near it.

2015-01-07 03:04:30 -0500 commented answer Real world coordinates from a pixel

I can't use a reference point because the stereo are mounted in a robot arm. I read about other solution that use the opencv function reprojectImageTo3D() but I need the disparity array and Q matrix, but I'm not sure if I'm on the right direction.

2015-01-05 09:26:40 -0500 asked a question Real world coordinates from a pixel

Hi I'm new in opencv and I have a problem: I don't know which are the steps to obtain the pose an orientation (in the real world) to the one pixel of my image. I read about it but it is not clear for me. I have a calibrated camera stereo and I get the pixel coordinate of interest, but I don't know how to continue. Can anyone help me? Thanks!!