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.