Click here to Skip to main content
13,501,210 members
Rate this:
Please Sign up or sign in to vote.
See more: , +

after calibration and undistortion using opencv, I have this image and I need to remove the black borders(crop the image)only depending on the camera parameters which I have in the output XML file so how I can define the region of interest?[^]

<Camera_Matrix type_id="opencv-matrix">
    1.3117098501208040e+003 0. 6.9550000000000000e+002 0.
    1.3117098501208040e+003 520. 0. 0. 1.</data></Camera_Matrix>
<Distortion_Coefficients type_id="opencv-matrix">
    -2.1400301530776253e-001 4.6169624608789456e-002 0. 0.
<Per_View_Reprojection_Errors type_id="opencv-matrix">
    3.56106251e-001 3.05902541e-001 3.21639299e-001 3.97623330e-001
    4.79688823e-001 3.31597805e-001 2.92068005e-001 3.66955608e-001
    3.19793940e-001 6.19786203e-001 4.36506212e-001 3.26359451e-001
    3.68108034e-001 2.78367579e-001 2.72553772e-001 2.62321293e-001</data></Per_View_Reprojection_Errors>
<!-- a set of 6-tuples (rotation vector + translation vector) for each view -->
<Extrinsic_Parameters type_id="opencv-matrix">
    8.2524798674623173e-002 1.1957588136538763e-002
    -5.2492873372617030e-002 -8.7280621973657318e+001
    -3.9451553914075618e+001 5.7852359123958058e+002
    -2.0676032091414645e-001 -6.0286278602077602e-002 ...
    <Image_points type_id="opencv-matrix">
    4.99537811e+002 4.31490295e+002 5.57311035e+002 4.28100739e+002
    6.15545166e+002 4.24772125e+002 6.74481750e+002 4.21481506e+002
    7.33297974e+002 4.18324432e+002 7.91958740e+002 4.15214600e+002
    8.51019897e+002 4.12198181e+002 9.09479858e+002 4.09300568e+002
    9.67362793e+002 4.06486938e+002 5.02951508e+002 4.89633362e+002
Posted 24-Feb-14 21:14pm
Updated 24-Feb-14 21:18pm
It's really hard to understand how it's possible that anyone performing such a complex operation as distortion compensation don't know how to do elementary crop. How come?... :-)
The_Inventor 25-Feb-14 5:30am
GetOriginalRect(); GetSelectRect(); DeleteRectDiff(GetOriginalRect()- GetSelectRect());
NewRect = GetOriginalRect() - DeleteRectDiff(GetOriginalRect()- GetSelectRect());

Or something like this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180417.1 | Last Updated 25 Feb 2014
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100