Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hallo,

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?

https://picasaweb.google.com/118430866477186313381/25Februar2014#5984243944425984322[^]

HTML
<Camera_Matrix type_id="opencv-matrix">
  <rows>3</rows>
  <cols>3</cols>
  <dt>d</dt>
  <data>
    1.3117098501208040e+003 0. 6.9550000000000000e+002 0.
    1.3117098501208040e+003 520. 0. 0. 1.</data></Camera_Matrix>
<Distortion_Coefficients type_id="opencv-matrix">
  <rows>5</rows>
  <cols>1</cols>
  <dt>d</dt>
  <data>
    -2.1400301530776253e-001 4.6169624608789456e-002 0. 0.
    1.8396036701643875e-001</data></Distortion_Coefficients>
<Avg_Reprojection_Error>3.6924789370054928e-001</Avg_Reprojection_Error>
<Per_View_Reprojection_Errors type_id="opencv-matrix">
  <rows>16</rows>
  <cols>1</cols>
  <dt>f</dt>
  <data>
    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">
  <rows>16</rows>
  <cols>6</cols>
  <dt>d</dt>
  <data>
    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">
  <rows>16</rows>
  <cols>54</cols>
  <dt>"2f"</dt>
  <data>
    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
Updated 24-Feb-14 21:18pm
v2
Comments
Sergey Alexandrovich Kryukov 25-Feb-14 3:29am    
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?... :-)
—SA
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900