Slabs photo panorama/stitching automatic software

89 views
Skip to first unread message

Matteo Mazzoni

unread,
Aug 3, 2024, 7:43:33 AM8/3/24
to hugin and other free panoramic software
Hello,

We are an Italian company named : Iride www.iridefoto.it

we have developed an automatic photography system for marble slabs.
We are taking photographs of marble slabs passing through the polishing line.

The photography position is fixed, meaning we always have the same shot.

We have to compose the final marble slab starting, for example, from about ten photographs.
We take a picture every 60cm and the final slab will be for example around 350cm.
The pictures have overlapping areas to facilitate the joining.

We have tryed to crop the photographs selecting only the marble part before to perform the final algo.
Basically we need to have a photo stitching solution.

We will prefer to have a solution with Python as our script is already written with this language.

The script doesn't have to a "real-time one"
We can process the pics and after "minutes/hour" produce the result for every slab

We have a demo of the images here :
https://drive.google.com/drive/folders/1pkYErc_4Kdzajqlno6zACtNJRZJJ4GWp?usp=sharing

We have played with this project on Git: with no good result.
https://github.com/OpenStitching/stitching


This is a job request that provides compensation to anyone who can provide a software solution.

Many thanks for your help.
www.iridefoto.it

Claudio Rocha

unread,
Aug 4, 2024, 4:23:56 AM8/4/24
to hugin and other free panoramic software

I think that you can do this in hugin through scripting.

The basic workflow would be like the way scanned images are stitched together:


The idea is to treat each image as a different lens in the hugin file, and stitch them as mosaic plane using a rectangular projection.
Think of the camera as if it was moving on a rail over the stationary slabs. For the optimization, hugin should deal only with movement in X and Y axis (and maybe rotation).  

For the camera original photos I would suggest to use a format that is not jpeg, shoot raw and work with images with a bit depth of 16 bits per color. More on that below.

The first image you need is a photo of the empty conveyor belt without any slabs. Just the empty space using the same lens and light.

Use that first image to automatically subtract the background from all of the images with slabs of marble. 
Generate what is called a "difference mask" or a "difference matte", and use that to add black, white or alpha around the slabs of marble.

For automated scripting that can be done with imagemagik


This will work best if the original files have no jpg compression artifacts. Shoot raw and convert to 16 bit tiff or png files.
Having images without a background will make it easier for Hugin to create control points that are only within surface of the slabs, and not in the conveyor belt.

Once you have a series of images that contain only the slabs, then you can run a script.
Here's an example in bash, but I'm sure porting it to python should not be difficult.
The goal of the script is to process a series of images on the current directory and stitch them together.

#! /bin/sh
# hugin command tools script to stitch images as a mosaic plane
# use of fov >= 10 should be OK, could simply set FOV=10

# set fov value
FOV=10

#create a .pto project using all jpg files in current directory
pto_gen --projection=0 --fov=$FOV -o project.pto *.JPG
#modify accordingly for tiff, or other formats

# for loop that counts how many images exist, and then assigns a new lens to each one.
#modify for different image formats if needed.
for I in $(seq 1 $(ls -f *JPG | wc -l))
      do
      pto_lensstack -o 01_project.pto --new-lens i$I project.pto
done

#find control points
cpfind --prealigned -o 02_control_points.pto  01_project.pto

#clean control points
cpclean -v --max-distance=1 --pairwise-checking -o 03_clean_cp.pto 02_control_points.pto


# Optomization is set to rotation, X and Y coordinates.

pto_var -o 04_set_optim.pto --opt r,TrX,TrY,!r0,!TrX0,!TrY0 03_clean_cp.pto
# if rotation creates problems then change to -opt TrX,TrY,!TrX0,!TrY0


#calculate the panorama using all the control points and set parameters
autooptimiser -n -o 05_auto_optim.pto 04_set_optim.pto

#set the projection to rectilinear and calculate cropping
pano_modify  --projection=0 --fov=AUTO --center --canvas=100% --crop=AUTO -o 06_final_stitch_project.pto 05_auto_optim.pto


You can use the hugin user interface to check each of the projects along the way,  and understand the logic behind it, and troubleshoot any problems.

Claudio Rocha

unread,
Aug 4, 2024, 6:12:35 AM8/4/24
to hugin and other free panoramic software
Difference key is not going to work, sorry for the bar idea. 
Try placing the slabs over a flat surface, a board or something opaque and that has a flat color (black, white, green or blue screen) so that you have a clear separation between what is marble, and what isn't. if you manage to automate finding and masking the edges of the slabs, then finding control points and stitching the pictures should be easier to automate.
 
Reply all
Reply to author
Forward
0 new messages