简体   繁体   中英

Change value of the camera focal in pixels

I am currently looking for a proper solution to the following problem, which is not directly programming oriented, but I am guessing that the users of opencv might have an idea: My stereo camera has a sensor of 1/3.2" 752x480 resolution. I am using the two stereo images of this very camera in order to create a point cloud, thanks to the point cloud library (PCL). The problem is that I would like to reduce the number of points contained by the point cloud, by directly lowering the resolution of the input images (passing from 752x480 to 376x240). As it is indicated in the title, I have to adapt the focal of the camera in pixels to this need: I calculate this very parameter thanks to the following formula:

float focal_pixel = (FOCAL_METERS / SENSOR_WIDTH_METERS)*InputImg.cols;

However the SENSOR_WIDTH_METERS is currently constant and corresponds to the 1/3.2" data converted to meters AND I would like to adapt this to the resolution that I would like to have: 376x240.

I am absolutly not sure if I turned my problem clearly enough to be answered, which would mean that I am going in the wrong direction.

Thank you in advance

edit: the function used to process the stereo image (after computing):

getPointCloud(hori_c_pp, vert_c_pp, focal_pixel, BASELINE_METERS, out_stereo_cloud, ref_texture);

where the two first parameters are just the coordinates of the center of the image, BASELINE_METERS the baseline of my camera out_stereo_cloud my output cloud and eventually ref_texture the color information. This function is taken from the sub library stereo_matching. For some reason, if I just resize the stereo images, it seems to enter in conflict with the focal_pixel parameters, since the dimension are not the same anymore. Im very lost on this issue.

As I don't really follow the formulas and method calls you're posting I advise you to use another approach.

OpenCV already gives you the possibility to create voxels using stereo images with the method cv::reprojectImageTo3D . Another question also already discusses the conversion to the according PCL datatype.

If you only want to reproject a certain ROI of your image you should opt for cv::perspectiveTransform as is explained in the documentation I pointed out in the first link.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM