Hello / Hallo

> Am I right to assume that you are finding your control points
> via command line, using cpfind and wish to have a command
> line method of fine tuning those control points?

Yes, you're right, my exact command is:
cpfind --fullscale --celeste --multirow -o ptoFileName.pto ptoFileName.pto

And my idea was to drop CPoints that had a questionable correlation value.


> In case you haven't looked in detail at the cpfind options, you
> can use  --fullscale which may provide "better" control points.

Totally right. I confirm: It takes few more seconds (minutes with older CPU 
and less memory) but gives better results. I was using this one also.


> There are also a number of parameters for fine-tuning, such
> as --sieve1width, --seive1height etc which may help.

Good idea. I left those options aside, but I wonder if I would get more 
trustful CPoints by using smaller --sieve1* values...


> In addition, the command line tool cpclean has options
> to remove any generated control points with errors bigger
> than a specified value.

I use it also. But I understood that it removes points based on points "too 
far" from their position. Ideally, I would like to use it as a "second 
pass". The "first pass" would the correlation.


> Does any of this help?

Yes, always. By confirming my thoughts and giving some ideas... (sievel*)



> I don't see the point of fine-tune cp from the command line.
> Cpfind and align_image_stack set the cp already with sub-pixel
> accuracy. So fine-tune is not helpful.

I don't know how cpfind works in details but I always got CPoints with 
correlation below 0.5 (generally in some "blurry" areas, in the middle of a 
bigger pattern). I believe that this might be because cpfind works on 
bigger areas to find similarities while fine-tune option of hugin works on 
smaller search area.
My idea would be to drop the points that cannot be aligned at pixel-level 
(with high-contrast details in a small region).

(Regarding align_image_stack, I did not use it as I am focusing on panorama 
now, but useful to know anyway).


> Fine-tune has its application when setting cp
> by hand and then fine-tune the rough position.

Partially agree:
Fine-tune is extremely useful and saves a huge time when adding manual 
points.
But
It is also extremely useful to automatically estimate how "trustful" are 
the control points that cpfind created automatically. Especially with the 
"Edit > Fine-tune all Points" option.
When proceeding manually, right after having cpfind created the points, I 
"Fine-tune all Points" and then delete all the CPoints that are below 0.6 
"distance" (that is correlation value at this point). I prefer creating my 
own extra CPoints if needed.

----------

Some more details on my target: I often take panoramas and people request 
to have those quickly on the web. So my aim here is to automate the 
creation of panorama from a set of pictures. 
Sunday afternoon, I created the Python script attached to this message. 
That does most of the work.
The same is also there:
http://t.baeckeroot.free.fr/createPanorama.py
(I'll update on my site)
(feel free to adapt and/or revert to me and/or re-use it in any way you 
want. I build this for me: Python 2.7, Linux, Hugin 2011.4)

In brief my idea was to:
A- load the pictures composing a panorama
B- create Control-Points (cpfind)
C- Fine-tune them and drop CPoints that had correlation < 0.6
D- optimise alignment (autooptimiser and pano_modify)
E- drop CPoints that were statistically "too far" (cpclean)
F- create "final draft image" (nona and enblend)

Result is not perfect but enough for web. And fully automated.

The only missing part is C- to get the correlation value of the CPoints (to 
drop the less trustful).
If I can "Fine-tune all Points" and get the correlation value (in place of 
distance in hugin), then I believe I would be able to delete the CPoints 
from Python.

In my script, this is the part:
"
######## ( File > Preferences > Control Points Editor > Correlation 
Threshold: lower to 0.4 ) ########
######## Edit > Fine-tune all Points ########

######## Drop the CPoints that have correlation (distance) < 0.6 ########
"



Thanks Terry and Thomas

-- 
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
--- 
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/3cd78c45-5a02-48f0-89e2-b2a8de0ed3ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#!/usr/bin/python
###############################################################################
# Aim of this script is to create automatically a panorama from a set of
# pictures (separated in a folder).
# Folder containing the pictures is the only parameter of this script.
#
# Note:
# This script is written
# in Python:		tested with 2.7
# for running in Linux:	Mint 16
# with Hungin:		v2011.4.0
###############################################################################
# Date		Author			Modification description
#------------------------------------------------------------------------------
# 2014-09-14	Thomas BAECKEROOT	CREATION
#		([email protected])
#------------------------------------------------------------------------------
#
###############################################################################
print("Starting automatic panorama creation...")

from sys import argv
from hsi import *         # load the module
import os

argList = list(argv)

# Constants:
# Folder to analyse / take picture from:
panoFolder = argList[1]

######## make a new Panorama object ########
pano=Panorama()

######## Add pictures from the given folder to the newly created .pto ########
# Normalise photoFolder (add '/' if not already included at the end):
if panoFolder[len(panoFolder)-1] <> '/':
	panoFolder = panoFolder + '/'
# List files (images) in folder:
contenuDossier = os.listdir( panoFolder )
contenuDossier.sort()

# Create the list of image files (JPG) and add them to panorama:
fichiersImages = list()
for fileName in contenuDossier:
	if fileName[-4:] == '.JPG':
		fichiersImages.append(fileName)
		img = SrcPanoImage(panoFolder+fileName)
		print("%r < addImage(%r) " % ( pano.addImage(img) , fileName ) )
	else:
		print("    ignored file: %r" % fileName )

# Extract the name of the folder containing the images (without path, this will be used as prefix)
i = 0
for i in range(len(panoFolder)-2, -1, -1):
	if panoFolder[i] == '/':
		break
firstCharOfLastFolder = i+1
ptoBaseName = panoFolder[firstCharOfLastFolder:-1]
ptoFileName = ptoBaseName + "_00.pto"
ptoCleanFileName = ptoBaseName + "_01.pto"
parentOfPanoFolder = panoFolder[0:firstCharOfLastFolder-1]
# Save .pto file:
ofs=ofstream(panoFolder+ptoFileName)    # make a c++ std::ofstream to write to
pano.writeData(ofs)                     # write the modified panorama to that stream
ofs.flush()

######## Create the Control Points ########
cpfindCommandLine = "cpfind --fullscale --celeste --multirow -o \""+panoFolder+ptoFileName+"\" \""+panoFolder+ptoFileName+"\""
## option "-n 4" can allow to paralellize on 4 CPUs, etc...
print( "-" * 80 )
print( cpfindCommandLine )
os.system( cpfindCommandLine )

######## Align images (= optimise) ########
print( "\n" + "-"*80 + "\nautooptimiser..." )
os.system("autooptimiser -a -l -s -m -o \""+panoFolder+ptoFileName+"\" \""+panoFolder+ptoFileName+"\"")

######## Optimise: Strainghten, Centre, Autocrop and Calculate Optimal Size ########
print( "\n" + "-"*80 + "\npano_modify...")
os.system("pano_modify -s -c --canvas=AUTO --crop=AUTO -o \""+panoFolder+ptoFileName+"\" \""+panoFolder+ptoFileName+"\"")

######## ( File > Preferences > Control Points Editor > Correlation Threshold: lower to 0.4 ) ########
######## Edit > Fine-tune all Points ########

######## Drop the CPoints that have correlation (distance) < 0.6 ########

''' # Uncomment this part once upper Fine-tuning is implemented
######## Optimise (again) ########
print( "\n" + "-"*80 + "\nautooptimiser..." )
os.system("autooptimiser -a -l -s -m -o \""+panoFolder+ptoFileName+"\" \""+panoFolder+ptoFileName+"\"")

######## Optimiser: Redresser, Centrer, calculer la taille optimale ########
print( "\n" + "-"*80 + "\npano_modify...")
os.system("pano_modify -s -c --canvas=AUTO --crop=AUTO -o \""+panoFolder+ptoFileName+"\" \""+panoFolder+ptoFileName+"\"")
'''

######## Supprimer les points non significatifs  ########
print( "\n" + "-"*80 + "\ncpclean..." )
os.system("cpclean -o \""+panoFolder+ptoCleanFileName+"\" \""+panoFolder+ptoFileName+"\"")

######## Optimiser les alignements d'images (2nde passe apres alignement initial) ########
print( "\n" + "-"*80 + "\nautooptimiser..." )
os.system("autooptimiser -a -l -s -m -o \""+panoFolder+ptoCleanFileName+"\" \""+panoFolder+ptoCleanFileName+"\"")

######## Optimise (again): Strainghten, Centre, Autocrop and Calculate Optimal Size ########
print( "\n" + "-"*80 + "\npano_modify...")
os.system("pano_modify -s -c --canvas=AUTO --crop=AUTO -o \""+panoFolder+ptoCleanFileName+"\" \""+panoFolder+ptoCleanFileName+"\"")

'''
######## Compute final picture (reference method through makefile) ########
# Note: does NOT support JPEG output
#create stitching makefile
pto2mkCommandLine = "pto2mk -o \""+panoFolder+ptoBaseName+"_01.mk\" -p \""+panoFolder+ptoBaseName+"_01\" \""+panoFolder+ptoCleanFileName+"\""
print( "-" * 80 )
print( pto2mkCommandLine )
os.system( pto2mkCommandLine )

#create the final panorama
makeCommandLine = "make -f \""+panoFolder+ptoBaseName+"_01.mk\" all clean"
print( "-" * 80 )
print( makeCommandLine )
os.system( makeCommandLine )

######## Convert output tiff to jpg in parent folder ########
'''

######## Compute final picture (alternative method: nona + enblend) ########
# Following instructions from file:///usr/share/hugin/xrc/data/help_en_EN/Panorama_scripting_in_a_nutshell.html
nonaCommandLine = "nona -m TIFF_m -o \""+panoFolder+ptoBaseName+"_01_\" \""+panoFolder+ptoCleanFileName+"\""
print( "-" * 80 )
print( nonaCommandLine )
os.system( nonaCommandLine )

filesCreatedByNona = list()
enblendCommandLine = "enblend -o \""+parentOfPanoFolder+"/"+ptoBaseName+"_01.jpg\""
for i in range( len(fichiersImages) ):
	fileCreatedByNona = panoFolder+ptoBaseName+"_01_%04d.tif" % i
	filesCreatedByNona.append( fileCreatedByNona )
	enblendCommandLine = enblendCommandLine + " \""+fileCreatedByNona+"\""

print( "-" * 80 )
print( enblendCommandLine )
os.system( enblendCommandLine )


######## Remove intermediary/temporary tiff files ########
print("Deleting intermediary files: %r" % filesCreatedByNona)
for i in range( len(filesCreatedByNona) ):
	os.remove( filesCreatedByNona[i] )

print("Terminated.")
exit(0)

# Exit codes:
#   0	Normal exit

Reply via email to