Showing posts with label Matlab. Show all posts
Showing posts with label Matlab. Show all posts

Sunday, 17 June 2012

Automatic Multiple Cameras Calibration Matlab Toolbox

Recently we release an Automatic Multiple Cameras Calibration Matlab Toolbox (amcctoolbox) through group codes.

This toolbox is developped based on current widely used Bouget's Camera Calibration Toolbox for Matlab and also integrated the corner detection implementation from Robust Automatic Detection Of Calibration Chessboards (RADOCC) toolbox.

Feel free to play with this toolbox with your calibration datasets.

Download here using the following link.

Thursday, 3 May 2012

matlab script on converting ply to pcd

PCL from willow garage is really useful for 3D geometric process and visualization, and it requires its own data format, say, point cloud data (pcd). In pcd file, the x, y, z coordinates are stored as float datatype, while color information rgb is packed into a 4 byte unsigned integer. I know it could use float to represent the rgb(a) information, unfortunately I did not make this work properly.

I wrote two matlab scripts to convert ply file generated by meshlab to pcd. One that I called as naive one, which scan each line in ply and then write them into pcd with appropriate format. The other one that I referred as efficient one due to data block can be read and written only once, it is about 10 times faster than the naive one for large file.

With respect to color conversion, as the color is stored as 8-bit unsigned integer for r, g, b channel in ply, while rgb is packed as  32-bit unsigned integer in pcd. I convert r, g, b from decimal to hex, and then pack them together and convert them back to decimal format. 

N.B.: currently it only supports the ply file with x,y,z or x,y,z, r,g,b information.
Download:

Sunday, 22 April 2012

[FIND] function in MATLAB

Matlab is really a good tool to implement some brainstorm idea in quick way, however, for loop is not efficient especially for large database search problem. FIND built-in function can solve the problem very well. Now I understand why the runtime of compilation-based code is much more efficient than interpretation-based program.

For example, the first program is several orders of magnitude faster than the second one.

% The codes with find

for i = 1:NumQuadrats
    tic
    ind = find(x >= xmin + (i - 1)*step & x < xmin + i*step);
    quadrat{i} = [x(ind) y(ind) z(ind)];
    x(ind) = [];
    y(ind) = [];
    z(ind) = [];
    fprintf('Quadrat %d has been done !\n', i);
    toc
end

% The codes without find

for i = 1:NumQuadrats
    index = [];
    tic
    for j = 1:size(x,1)
        if x(j) >= xmin + (i - 1)*step && x(j) < xmin + i*step
            quadrat{i} = [quadrat{i};[x(j) y(j) z(j)]];
            index = [index;j];
        end
    end
    x(index) = [];
    y(index) = [];
    z(index) = [];
    fprintf('Quadrat %d has been done !\n', i);
    toc
end