doda42/LFToolbox

How to get "CalInfo.json" for a lfp image?

jhss opened this issue · 12 comments

jhss commented

While I followed "Light Field Toolbox for Matlab", I have a problem
I created a folder as follows.

Samples
     Cameras
         A123
             Beers.lfp(sample image)
             WhiteImages

And I ran the following code

LFUtilUnpackLytroArchive -> LFUtilProcessWhiteImages

So I got white image database, and I would like to get calibration information from lfp image.
I got a sample image, named "Beers.lfp" from Lytro dataset. Then I ran LFUtilCalLensletCam(ImagePath), but I got the error

==Locating light fields in path/LFToolbox0.3_Samples1/Cameras/A123/Beers.lfp===
Searching for files [ Beers.lfp ] in path/LFToolbox0.3_Samples1/Cameras/A123
Found :
'Beers.lfp'

Checking zoom / focus / serial number across all files...
Error using load
Number of columns on line 5 of ASCII file
path/LFToolbox0.3_Samples1/Cameras/A123/Beers.lfp must be the same as
previous lines.

Error in LFCalFindCheckerCorners (line 64)
load(fullfile(BasePath, CurFname), 'LFMetadata');

Error in LFUtilCalLensletCam (line 121)
CalOptions = LFCalFindCheckerCorners( InputPath, CalOptions );

How could I get calibration information for a lfp image?

Have you tried reading through the "Quick Tour" chapter (Ch3) of LFToolbox.pdf ? Ch5 covers calibration in more detail. Note that you do not need to calibrate your camera to decode its images to 4D.

jhss commented

Thank you for answering

I read it, but some part don't make sense.
Actually, I got (i, j, k, l) coordinate of "Beers.lfp" when I ran "LFLytroDecodeImage", and i would like to transform it into (u, v, s, t) coordinate. So I tried to find transformation matrix H, and I think it's in the "CalInfo.json". This is the reason why I want to calibrate the image.

Is my understanding wrong? How can I get transformation matrix H in the image?

You're right, mapping pixels (i,j,k,l) to rays (s,t,u,v) requires calibration. This means you need to calibrate your camera.

The toolbox follows a procedure very similar to the standard 2D checkerboard calibration https://au.mathworks.com/help/vision/ug/single-camera-calibrator-app.html

You need to collect images of a checkerboard pattern using the camera you want to calibrate, at the zoom and focus setting you'd like to calibrate. Then process the images and run the calibration following the instructions in the documentation, Section 3.6 lays out the steps.

jhss commented

Thank you very much. Would I ask one more question?

I would like to get (s,t,u,v) of "Lytro dataset".
In the file, there is a folder named "Calibration", and there are files named "MOD_00**.GCT" in the folder. Can I use "MOD_00**.GCT" file for calibrating the camera?

The GCT files are part of the data that comes loaded onto the Lytro camera, along with the white images. The toolbox doesn't know how to interpret those files.

jhss commented

So, is there no way to get intrinsic matrix of Lytro dataset without buying Lytro camera and making a checkboard pattern?

Calibration is for a single, specific camera, at a single, specific zoom and focus setting. Buying a new camera and calibrating it will not tell you about the camera used to collect the dataset.

Any Lytro dataset was captured with a specific camera. That specific camera is the one you want to calibrate. Each camera will be slightly different due to manufacturing variation, and each dataset will be captured with different zoom and focus settings. The person collecting the dataset is generally in the best position to a) fix focus and zoom for the dataset; and b) provide checkerboard images for that focus and zoom setting, measured with the same camera as the dataset.

I'm happy to help with questions like this, you might also try the forum here: https://groups.google.com/forum/#!forum/lightfieldvision

jhss commented

Thank you for very detailed answer!
your answer really help me and I now get to know specific calibration process.

@doda42 Hi, a quick question regarding the dataset referred to in this thread, there are some .GCT files, incloud.txt, sha1.txt and data.C.x (which seem like the white image files) files , but no MOD_.TXT files. So the toolbox is unable to find the white images. However the dataset website (https://www.irisa.fr/temics/demos/lightField/index.html) says it is there and we should be able to decode using this toolbox and this dataset is also linked on your website. This is a first generation Lytro dataset, should the toolbox look for some other extension perhaps, am I missing something?

Summary, using toolbox v0.5.1:

  • Reorganise the folders to match the toolbox expectation: cameras go in a Cameras folder, images go in an Images folder
  • Run LFUtilUnpackLytroArchive from the top folder
  • Proceed with the usual decode procedure:
  • Run LFUtilProcessWhiteImages to find lenslets and build a white image database
  • Run LFUtilDecodeLytroFolder

In detail:

I moved the sn-A303134643 folder into a folder called "Cameras" to match the toolbox expectation of folder structure*. Similarly, I moved the files in "raws" into a folder called "Images", alongside the "Cameras" folder.

There is a set of Data.C. files in sn-A303134643 that need to be uncompressed. This is the same procedure you would follow if this were your camera, and it's described in Appendix A1 of LFToolbox.pdf. Run LFUtilUnpackLytroArchive from the top level of the dataset folder.

Again, from the top of the dataset folder, follow the instructions in Sec 3.1.2 of LFToolbox.pdf. Run LFUtilProcessWhiteImages, then run LFUtilDecodeLytroFolder.

Hope that helps!

  • you can also maintain the existing structure by passing directory specifications into the toolbox functions, but I found it more convenient to reorganise the dataset in this case

It helps and more. Thank you!