Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2016-10-05 12:36:00 -0600

Nbb gravatar image

ProjectPoints not working

I have an image with a disparity map that I reproject to 3D. After running some algorithms to extract the bounding box in 3D, i reprojected each corner back to 2D to find the minimum bounding box but the results I get are totally wrong. I have verified that the corners in 3D are in the right position. But when reprojected onto 2D it becomes wrong. Been trying to figure out the problem for days and have no progress.

1) Reconstruct 3d 2) Run algorithm to get bounding box in 3d 3) Reproject the corners of each bounding box in 2d (projected points error) 4) Get minimum enclosing bounding box in 2d

image description

image description

Does anyone have any idea what is going on ? I am only using the function projectpoints(); Someone please offer some suggestion.

ProjectPoints not working

I have an image with a disparity map that I reproject to 3D. After running some algorithms to extract the bounding box in 3D, i reprojected each corner back to 2D to find the minimum bounding box but the results I get are totally wrong. I have verified that the corners in 3D are in the right position. But when reprojected onto 2D it becomes wrong. Been trying to figure out the problem for days and have no progress.

1) Reconstruct 3d
2) Run algorithm to get bounding box in 3d
3) Reproject the corners of each bounding box in 2d (projected points error)
4) Get minimum enclosing bounding box in 2d

2d

image description

image description

Does anyone have any idea what is going on ? I am only using the function projectpoints(); Someone please offer some suggestion.

ProjectPoints not working

I have an image with a disparity map that I reproject to 3D. After running some algorithms to extract the bounding box in 3D, i reprojected each corner back to 2D to find the minimum bounding box but the results I get are totally wrong. I have verified that the corners in 3D are in the right position. But when reprojected onto 2D it becomes wrong. Been trying to figure out the problem for days and have no progress.

1) Reconstruct 3d
2) Run algorithm to get bounding box in 3d
3) Reproject the corners of each bounding box in 2d (projected points error)
4) Get minimum enclosing bounding box in 2d

image description

image description

Does anyone have any idea what is going on ? I am only using the function projectpoints(); Someone please offer projectpoints();

Original Image Size : 1392 x 512 Calibrated Image Size : 1242 x 375 (This is the image I am working with)

EDIT: These are just the relevant portions of the code I think.

// Get Q Matrix    
stereoRectify(K1, D1, K2, D2, cv::Size(1392, 512), R, T, R1, R2, P1, P2, Q, cv::CALIB_ZERO_DISPARITY, 0, cv::Size(1242, 375), 0, 0);

// Project image to 3D
disparity = disparity / 500.f
cv::reprojectImageTo3D(disparity, out, Q, true);

// Do some suggestion.processing
// ....

// Reproject back to image
// opencv_cloud is a vector containing the 8 corners of a bounding box
// opencv_crd is a vector containing the projected points
cv::projectPoints(opencv_cloud, rvec, tvec, K1, cv::Mat(), opencv_crd);
all_points.push_back(cv::Mat(opencv_crd));

Thus I used the left camera matrix to reproject the points. rvec and tvec are both [0, 0, 0]. I have tried replacing cv::Mat() with the distortion matrix of the left camera but it seems like there is no effect. Could it be the image resolution ? Is it reprojecting onto the image with the original resolution ?

ProjectPoints not working

I have an image with a disparity map that I reproject to 3D. After running some algorithms to extract the bounding box in 3D, i reprojected each corner back to 2D to find the minimum bounding box but the results I get are totally wrong. I have verified that the corners in 3D are in the right position. But when reprojected onto 2D it becomes wrong. Been trying to figure out the problem for days and have no progress.

1) Reconstruct 3d
2) Run algorithm to get bounding box in 3d
3) Reproject the corners of each bounding box in 2d (projected points error)
4) Get minimum enclosing bounding box in 2d

image description

image description

Does anyone have any idea what is going on ? I am only using the function projectpoints();

Original Image Size : 1392 x 512 512

Calibrated Image Size : 1242 x 375 (This is the image I am working with)

EDIT: These are just the relevant portions of the code I think.

// Get Q Matrix    
stereoRectify(K1, D1, K2, D2, cv::Size(1392, 512), R, T, R1, R2, P1, P2, Q, cv::CALIB_ZERO_DISPARITY, 0, cv::Size(1242, 375), 0, 0);

// Project image to 3D
disparity = disparity / 500.f
cv::reprojectImageTo3D(disparity, out, Q, true);

// Do some processing
// ....

// Reproject back to image
// opencv_cloud is a vector of point3f containing the 8 corners of a bounding box
// opencv_crd is a vector of point2f containing the projected points
cv::projectPoints(opencv_cloud, rvec, tvec, K1, cv::Mat(), opencv_crd);
all_points.push_back(cv::Mat(opencv_crd));
rect.push_back(cv::boundingRect(cv::Mat(opencv_crd)));

Thus I used the left camera matrix to reproject the points. rvec and tvec are both [0, 0, 0]. I have tried replacing cv::Mat() with the distortion matrix of the left camera but it seems like there is no effect. Could it be the image resolution ? Is it reprojecting onto the image with the original resolution ?

ProjectPoints not working

I have an image with a disparity map that I reproject to 3D. After running some algorithms to extract the bounding box in 3D, i reprojected each corner back to 2D to find the minimum bounding box but the results I get are totally wrong. I have verified that the corners in 3D are in the right position. But when reprojected onto 2D it becomes wrong. Been trying to figure out the problem for days and have no progress.

1) Reconstruct 3d
2) Run algorithm to get bounding box in 3d
3) Reproject the corners of each bounding box in 2d (projected points error)
4) Get minimum enclosing bounding box in 2d

image description

image description

Does anyone have any idea what is going on ? I am only using the function projectpoints();

Original Image Size : 1392 x 512

Calibrated Image Size : 1242 x 375 (This is the image I am working with)

EDIT: These are just the relevant portions of the code I think.

// Get Q Matrix    
stereoRectify(K1, D1, K2, D2, cv::Size(1392, 512), R, T, R1, R2, P1, P2, Q, cv::CALIB_ZERO_DISPARITY, 0, cv::Size(1242, 375), 0, 0);

// Project image to 3D
disparity = disparity / 500.f
cv::reprojectImageTo3D(disparity, out, Q, true);

// Do some processing
// ....

// Reproject back to image
// opencv_cloud is a vector of point3f containing the 8 corners of a bounding box
// opencv_crd is a vector of point2f containing the projected points
cv::projectPoints(opencv_cloud, rvec, tvec, K1, cv::Mat(), opencv_crd);
rect.push_back(cv::boundingRect(cv::Mat(opencv_crd)));

Thus I used the left camera matrix to reproject the points. rvec and tvec are both [0, 0, 0]. I have tried replacing cv::Mat() with the distortion matrix of the left camera but it seems like there is no effect. Could it be the image resolution ? Is it reprojecting onto the image with the original resolution ?

EDIT: After scaling the camera matrix as suggested by Tetragramm, the results I get are much better.

image description