Panoramic pictures w/ PTZs?

Tolting Colt Acres

Pulling my weight
Joined
Jun 7, 2016
Messages
378
Reaction score
153
Anyone aware of a piece of linux command-line software, or method, by which a Hikvision PTZ camera could be used to create a panoramic photograph?

I'm assuming I can set, via a script (perl, php, etc.) the camera's x/y axis through the api using and then capture an image, traversing the x or y axis, capturing photos as I go along, which I can then pipe into another application to created a stitched image.

I'd like to automate this process to create a panoramic picture for weatherstation purposes.
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,680
Reaction score
14,041
Location
USA
I've done it before, not with a linux app/script though. I generate 60-80 or so images and feed them into Microsoft ICE to get outputs like this (obviously you can get much higher resolution outputs than this).

 

Tolting Colt Acres

Pulling my weight
Joined
Jun 7, 2016
Messages
378
Reaction score
153
Took me some time, but, I culled together a workable script. The panotools link was useful, but I had to install quite a bit of software -- much of it I had to download the source and compile manually, as RPMs were not available for my distro (CentOS 7.5) though various yum repositories.

Hugin was the worst. I had to download and compile a dozen different support libraries and utilities (newer version of cmake and boost, exiv, hdf5, lwxwidgets, fftw, openexr, exiftool, vigra, glew, ilmbase, hugin and enblend). Probably not for the faint of heart :)

I snap 7 pictures 46 degrees apart, with the cameras field of view it yields a near 360 degree image. Elevation is 18 degrees as to not capture the top of the enclosure. The camera expects values multiplied by 10 as the parameters for elevation and azimuth are expressed in 10ths of a degree.

This photo is taken on my camera mounted at the very top of my TX-455 tower (currently cranked down) so is about 40' above ground level. You can see bits and pieces of my A6270-13S, A3WS and A3S on the mast below.

 
Last edited:

Tolting Colt Acres

Pulling my weight
Joined
Jun 7, 2016
Messages
378
Reaction score
153
#!/bin/sh
move_camera () {
COUNTDOWN=0 ;
echo "<PTZData><AbsoluteHigh><elevation>$1</elevation><azimuth>$2</azimuth><absoluteZoom>00</absoluteZoom></AbsoluteHigh></PTZData>" | \
curl -X PUT -s -d @- http://user:pass@ip.address.of.camera/ISAPI/PTZCtrl/channels/1/absolute > /dev/null
echo -n Moving camera to $1 $2
until [ $COUNTDOWN -gt 59 ] ; do
curl -X GET http://user:pass@ip.address.of.camera/ISAPI/PTZCtrl/channels/1/status > /tmp/pano/status.txt 2>&1
E=`grep elevation /tmp/pano/status.txt | tr '>' ' ' | tr '<' ' ' | awk '{print $2}'`
A=`grep azimuth /tmp/pano/status.txt | tr '>' ' ' | tr '<' ' ' | awk '{print $2}'`
sleep 1;
if [ $E -eq $1 -a $A -eq $2 ] ; then
return 0;
fi
let COUNTDOWN+=1
done
return 1;
}

rm -f /tmp/pano/*
COUNTER=0

until [ $COUNTER -gt 6 ]; do
str="abcdefghijklmnopqrstuvwxyz"
fname="${str:$COUNTER:1}"
let AZIMUTH="$((0 + $COUNTER * 460))"
move_camera 180 $AZIMUTH
if [ $? -eq 1 ] ; then
echo Error encountered. aborting...
exit
fi
curl -s -X GET http://user:pass@ip.address.of.camera/ISAPI/Streaming/channels/1/picture > /tmp/pano/${fname}.jpg
echo ... CLICK!
let COUNTER+=1
done

echo Creating panoramic photo
cd /tmp/pano
pto_gen -o project.pto *.jpg
cpfind -o project.pto --multirow --celeste project.pto
cpclean -o project.pto project.pto
linefind -o project.pto project.pto
autooptimiser -a -m -l -s -o project.pto project.pto
pano_modify --canvas=AUTO --crop=AUTO -o project.pto project.pto
hugin_executor --stitching --prefix=project project.pto
convert project.tif project.jpg
cp -f project.jpg /var/www/html/pano.jpg
echo Finis!
 

SkyLake

Getting comfortable
Joined
Jul 30, 2016
Messages
358
Reaction score
301
Gigapan works like this. It is theoretical a PT mount, just like a PT(Z) IP camera. It can create real big panorama's.

If you could program a PTZ camera (i bet it could be done with HTTP API) , to take pictures at specified presets, left, right, up or down, and stitch them with Photoshop, Microsoft ICE, etc etc.

 

SkyLake

Getting comfortable
Joined
Jul 30, 2016
Messages
358
Reaction score
301
Not sure I'd want to put my Sony Alpha 99 on top of my tower though :D
Nah, me neither :D

But with the http api it would be possible to code a program that does the same as the gigapan. + waterproof also haha. Just without the MP a DSLR has :D
 

Tolting Colt Acres

Pulling my weight
Joined
Jun 7, 2016
Messages
378
Reaction score
153
Here's a slightly different version which traverses both the x and y axis. Takes a loooong time to run, though, matching up all the control points. Would go faster if I could find a way to pre-define the stitching order of the images, since I know what sequence they're taken in. Might help eliminate the stitching errors as well.

Code:
#!/bin/sh

move_camera () {
   COUNTDOWN=0 ;
   echo "<PTZData><AbsoluteHigh><elevation>$1</elevation><azimuth>$2</azimuth><absoluteZoom>00</absoluteZoom></AbsoluteHigh></PTZData>" | \
      curl -X PUT -s -d @- http://user:pass@w.x.y.z:p/ISAPI/PTZCtrl/channels/1/absolute > /dev/null
   echo -n Moving camera to $1 $2
   until [ $COUNTDOWN -gt 59 ] ; do
      curl -X GET http://user:pass@w.x.y.z:p/ISAPI/PTZCtrl/channels/1/status > /tmp/reh/status.txt 2>&1
      E=`grep elevation /tmp/pano/status.txt | tr '>' ' ' | tr '<' ' ' | awk '{print $2}'`
      A=`grep azimuth   /tmp/pano/status.txt | tr '>' ' ' | tr '<' ' ' | awk '{print $2}'`
      sleep 1;
      if [ $E -eq $1 -a $A -eq $2 ] ; then
         return 0;
      fi
      let COUNTDOWN+=1
   done
   return 1;
}

rm -f /tmp/pano/*
ELEVATION=180
until [ $ELEVATION -gt 900 ] ; do
   AZIMUTH=000
   until [ $AZIMUTH -gt 3150 ]; do
       printf -v fname "%03d%04d" $ELEVATION $AZIMUTH
       move_camera $ELEVATION $AZIMUTH
       if [ $? -eq 1 ] ; then
          echo Error encountered. aborting...
          exit
       fi
       curl -s -X GET http://user:pass@w.x.y.z:p/ISAPI/Streaming/channels/1/picture > /tmp/pano/${fname}.jpg
       echo ... CLICK! $fname
       let AZIMUTH+=450
   done
   let ELEVATION+=120
done

echo Creating panoramic photo
cd /tmp/pano
pto_gen -o project.pto *.jpg
cpfind -o project.pto --multirow --celeste project.pto
cpclean -o project.pto project.pto
linefind -o project.pto project.pto
autooptimiser -a -m -l -s -o project.pto project.pto
pano_modify --canvas=AUTO --crop=AUTO -o project.pto project.pto
hugin_executor --stitching --prefix=project project.pto
convert project.tif project.jpg
cp -f project.jpg /var/www/html/pano.jpg
echo Finis!
 
Joined
Jul 13, 2020
Messages
1
Reaction score
0
Location
Oklahoma
Wow, this is exactly what I am looking for, except I need it for an AXIS Q6128-E. Anyone have any familiarity with it?
 
Joined
Feb 18, 2022
Messages
1
Reaction score
0
Location
Moss Beach, CA
Anyone aware of a piece of linux command-line software, or method, by which a Hikvision PTZ camera could be used to create a panoramic photograph?

I'm assuming I can set, via a script (perl, php, etc.) the camera's x/y axis through the api using and then capture an image, traversing the x or y axis, capturing photos as I go along, which I can then pipe into another application to created a stitched image.

I'd like to automate this process to create a panoramic picture for weatherstation purposes.
I was uising ImageMagick for our webcam for years and now use Montage. Linux. We are uising an Axis PTZ and run it through an array of images and then uise Montage to stitch them up.

 
Top