oliver-batchelor / multical

Multi-camera calibration using one or more calibration patterns
Other
362 stars 67 forks source link

Confuse about commands running multiple cameras with multiple patterns #21

Closed zhaozhongch closed 2 years ago

zhaozhongch commented 2 years ago

I tried to run single camera with single calibration pattern successfully with the following command

multical calibrate --boards aprilgrid_6x6.yaml --cameras cam1 --camera_pattern 'data/{camera}'

I put my calibration image into

- data
  - cam1
     - im0.png
     - im1.png
     - im2.png
     - ...

The yaml file is

boards:
  aprilgrid_9x9:
    _type_: 'aprilgrid'
    size: [6, 6]
    tag_family: t36h11 # ['t16h5', 't25h7', 't25h9', 't36h11']
    tag_length: 0.06
    tag_spacing: 0.3

    min_rows: 2
    min_points: 12

Now I want to extend to two cameras, two patterns I change the data folder as the following, assume in each image I have two patterns can be seen

- data
  - cam1
     - im0.png
     - im1.png
     - im2.png
     - ...
   - cam2
     - im0.png
     - im1.png
     - im2.png
     - ...     

Yaml file aprilgrid_multiple.yaml

boards:
  aprilgrid_0:
    _type_: 'aprilgrid'
    tag_length: 0.07
    tag_spacing: 0.25
    size: [6, 6]
    start_id: 0
    min_rows: 2
    min_points: 12
  aprilgrid_1:
    _type_: 'aprilgrid'
    tag_length: 0.07
    tag_spacing: 0.25
    size: [6, 6]
    start_id: 48 # Start from different ID on different board
    min_rows: 2
    min_points: 12

From the instruction in the Readme and my understanding, I should run the commands as following

multical calibrate --boards aprilgrid_multiple.yaml --cameras cam1,cam2 --camera_pattern 'data/{camera}'

However, this command shows error

....
[Errno 2] No such file or directory: './data/cam1,cam2'

Looks it tries to look for a folder names cam1,cam2 instead of cam1 and cam2. Is this a bug or do I misunderstand how to input multiple cameras? Another question is, I am not sure how the library can distinguish two patterns in the image. I assume the start_id in the yaml file is used know different patterns but does that mean we should write an ID (like 0, 48) name on the pattern? Sorry, this question may sound naive but I am indeed not sure if it can just automatically detect two patterns and won't mix them up. Thanks in advance

zhaozhongch commented 2 years ago

For the first problem, after checking the code I found the correct format for multiple cameras is --cameras cam1 cam2 instead of --cameras cam1,cam2, there is no ,. Please modify the Readme a little bit.

For the second problem, to be more specific, assume now I have two images from two cameras, each image can see two patterns like the following

match

The patternA in image0 should match the patternA in image1 instead of pattern B in image1. How do I specify that or the code can automatically do this matching. If it is automatically matching, is there any chance the matching is wrong? I am not 100 percent sure how Apriltag matching works but from my intuition, there might be a pattern matching problem.

zhaozhongch commented 2 years ago

The way to distinguish the pattern is to use the id of the April tag. Each pattern's April id should be different. For example, pattern is a 6x6 pattern with id 0 to 35 then another one is a 6x6 pattern with id 36 to 71. In the reference paper, it includes the transformation between patterns into the least square optimization.

Ram-198 commented 1 year ago

Hi,

Currently, i am using 2 camera with 2 boards (different) for calibration. When i tried to calibrate the camera using following cmd

_>multical calibrate --boards charuco_multiple.yaml --cameras cam1 cam2 --camera_pattern 'data/{camera}'_

i am getting following error.

_return [filename for filename in natsorted(os.listdir(filepath)) FileNotFoundError: [WinError 3] The system cannot find the path specified: ".\'data/cam1'"_

My folder structure is

image

It would be great if you can help me with right cmd that i need to use to calibrate the 2 cameras (and generate intrinsic and extrinsic).

PS: i was able to to run intrisic camera calibration (could you also let me know, what cmd & folder structure needs to be used for do the extrinsic with fixed intrinsic)

Thank you in advance!!!