Forum

Author Topic: Using Metashape to remove distortion from CCTV cameras  (Read 965 times)

bpitanga

  • Newbie
  • *
  • Posts: 1
    • View Profile
Using Metashape to remove distortion from CCTV cameras
« on: January 24, 2024, 08:51:01 PM »
Hello,

I have a regular demand in my work of aligning CCTV captured images in 3D space point clouds (inverse camera). For that type of algorithm to work, it is necessary to remove the CCTV camera distortions prior to 3D alignment (and CCTV cameras introduce a lot of distortion). See the "Original.jpg" image attached for an exemple.

First, I´ve tried to follow this tutorial: https://agisoft.freshdesk.com/support/solutions/articles/31000160059-lens-calibration-using-chessboard-pattern-in-metashape. Based on that, I followed this workflow:

  • Captured the Metashape generated chessboard pattern using the same CCTV camera which captured the images I want to remove the distortions.
  • Loaded those images in a Metashape chunk.
  • Run the tools->lens->calibrate lens… algorithm.
  • Saved the calculated calibration parameters using the save button at the Camera Calibration dialog box (save the parameters as an XML files).
  • Created a new chunk and loaded the images to be undistorted.
  • With that chunk selected, opened the Camera Calibration dialog box, and loaded the XML file I generate in step 4. So, the Type option changed to precalibrated and the parameters were loaded inside the text boxes.
  • Exported the images using the option File -> Export -> Convert Images… with the Transform to initial calibration option checked.

So, that didn’t work. What I got was the same distorted original image with heavy cylindrical distortion added. See the attached "bad.jpg" image.

Then, I tried a variation of that workflow where I added the distorted images to the same chunk as the chessboard images, thus skipping the steps 4 to 6 above. Well, that just worked! See the "good.jpg" image attached.

So, what I’d like to know is why it didn’t work using the aforementioned workflow, with the export/import of the calibration parameters from one chunk to another. Is there something I’m forgetting to do?

Thanks in advance.
« Last Edit: January 24, 2024, 08:54:17 PM by bpitanga »

James

  • Hero Member
  • *****
  • Posts: 754
    • View Profile
Re: Using Metashape to remove distortion from CCTV cameras
« Reply #1 on: January 25, 2024, 02:00:30 PM »
As I understand it, the 'convert images' function will not convert a fisheye image to rectilinear, it'll just convert it to an ideal fisheye image, so perhaps you got lucky on the variation workflow where the camera type was still set to the default 'Frame' rather than 'Fisheye'?

Just a thought anyway!

Quote
Not sure if this is a bug or feature, but using the 'convert images' on a set of fisheye images, the output seems still to be a fisheye rather than rectilinear image.
Hello James,

The undistortion operation result corresponds to the selected camera type, so if the camera type is Fisheye, then you should get an "ideal" fisheye image.

Paulo

  • Hero Member
  • *****
  • Posts: 1350
    • View Profile
Re: Using Metashape to remove distortion from CCTV cameras
« Reply #2 on: January 25, 2024, 02:25:14 PM »
Hello.

the convert to initial calibration will eliminate distorsion defined in the Adjusted tab of Camera calibration. SO this what you are doing when loading images to the calibration chunk...It will eliminate the estimated calobration parameters..
You may look at https://agisoft.freshdesk.com/support/solutions/articles/31000168141-export-undistorted-photos
Best Regards,
Paul Pelletier,
Surveyor