# This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # graphics/pfscalibration # graphics/pfscalibration/files # graphics/pfscalibration/files/patch-src-jpeg2hdrgen # graphics/pfscalibration/files/patch-src-pfshdrcalibrate.cpp # graphics/pfscalibration/files/patch-src-robertson02.cpp # graphics/pfscalibration/files/patch-src-robertson02.h # graphics/pfscalibration/Makefile # graphics/pfscalibration/distinfo # graphics/pfscalibration/pkg-descr # graphics/pfscalibration/pkg-plist # echo c - graphics/pfscalibration mkdir -p graphics/pfscalibration > /dev/null 2>&1 echo c - graphics/pfscalibration/files mkdir -p graphics/pfscalibration/files > /dev/null 2>&1 echo x - graphics/pfscalibration/files/patch-src-jpeg2hdrgen sed 's/^X//' >graphics/pfscalibration/files/patch-src-jpeg2hdrgen << 'END-of-graphics/pfscalibration/files/patch-src-jpeg2hdrgen' X--- src/jpeg2hdrgen.orig Wed Aug 23 07:25:58 2006 X+++ src/jpeg2hdrgen Thu Jun 21 14:34:33 2007 X@@ -28,18 +28,25 @@ X export LC_ALL X X X-JHEAD="jhead" # program for extracting exif info from jpegs X- X-TEST_JHEAD=`which jhead`; X-if [ "$TEST_JHEAD" = "" ]; then X- echo "Program 'jhead' is required to run this script." X- echo "Install appropriate software, for example from:" X- echo "http://www.sentex.net/~mwandel/jhead/" X+JHEAD='jhead' # program for extracting exif info from jpegs X+EXIF='exif' # another one X+EXIV2='exiv2' # and one more X+ X+CMD=`which ${JHEAD}` X+[ -n "${CMD}" ] || CMD=`which ${EXIF}` X+[ -n "${CMD}" ] || CMD=`which ${EXIV2}` X+if [ -z "${CMD}" ] X+then X+ cat <graphics/pfscalibration/files/patch-src-pfshdrcalibrate.cpp << 'END-of-graphics/pfscalibration/files/patch-src-pfshdrcalibrate.cpp' X--- src/pfshdrcalibrate.cpp.orig Wed Aug 23 14:49:59 2006 X+++ src/pfshdrcalibrate.cpp Thu Jun 21 14:40:28 2007 X@@ -108,7 +108,7 @@ X { "help", no_argument, NULL, 'h' }, X { "verbose", no_argument, NULL, 'v' }, X { "luminance", no_argument, NULL, 'Y' }, X- { "fillin-response", no_argument, NULL, 'F' }, X+// { "fillin-response", no_argument, NULL, 'F' }, X { "calibration", required_argument, NULL, 'c' }, X { "gauss", required_argument, NULL, 'g' }, X { "max-response", required_argument, NULL, 'A' }, X@@ -123,7 +123,7 @@ X X int optionIndex = 0; X while( 1 ) { X- int c = getopt_long (argc, argv, "hvYFc:g:r:f:s:m:b:", cmdLineOptions, &optionIndex); X+ int c = getopt_long (argc, argv, "hvYFc:g:r:f:s:m:b:S:A:", cmdLineOptions, &optionIndex); X if( c == -1 ) break; X switch( c ) { X case 'h': X@@ -246,8 +246,8 @@ X throw pfs::Exception("calibration method not set or not supported"); X } X X- VERBOSE_STR << "interpolate missing parts of response: " X- << (opt_fillgaps ? "yes" : "no") << endl; X+// VERBOSE_STR << "interpolate missing parts of response: " X+// << (opt_fillgaps ? "yes" : "no") << endl; X X if( responseSaveFile!=NULL ) X VERBOSE_STR << "save response curve to a file (do not generate HDR image)" << endl; X@@ -434,6 +434,8 @@ X pfs::Channel *Xj, *Yj, *Zj; X frame->createXYZChannels( Xj, Yj, Zj ); X X+ // !!! this currently does more bad than good, relevant command line X+ // option is disabled X if( opt_fillgaps ) X { X if( opt_luminance ) X@@ -453,42 +455,50 @@ X } X X // calibration X+ long sp = 0; // saturated pixels X switch( opt_calibration ) X { X case NONE: X if( opt_luminance ) X { X VERBOSE_STR << "applying response to Y channel..." << endl; X- robertson02_applyResponse( Yj, imgsY, Iy, w, M); X+ sp = robertson02_applyResponse( Yj, imgsY, Iy, w, M); X } X else X { X VERBOSE_STR << "applying response to R channel..." << endl; X- robertson02_applyResponse( Xj, imgsR, Ir, w, M); X+ sp = robertson02_applyResponse( Xj, imgsR, Ir, w, M); X VERBOSE_STR << "applying response to G channel..." << endl; X- robertson02_applyResponse( Yj, imgsG, Ig, w, M); X+ sp += robertson02_applyResponse( Yj, imgsG, Ig, w, M); X VERBOSE_STR << "applying response to B channel..." << endl; X- robertson02_applyResponse( Zj, imgsB, Ib, w, M); X+ sp += robertson02_applyResponse( Zj, imgsB, Ib, w, M); X+ sp /= 3; X } X break; X case ROBERTSON: X if( opt_luminance ) X { X VERBOSE_STR << "recovering Y channel..." << endl; X- robertson02_getResponse( Yj, imgsY, Iy, w, M); X+ sp = robertson02_getResponse( Yj, imgsY, Iy, w, M); X } X else X { X VERBOSE_STR << "recovering R channel..." << endl; X- robertson02_getResponse( Xj, imgsR, Ir, w, M); X+ sp = robertson02_getResponse( Xj, imgsR, Ir, w, M); X VERBOSE_STR << "recovering G channel..." << endl; X- robertson02_getResponse( Yj, imgsG, Ig, w, M); X+ sp += robertson02_getResponse( Yj, imgsG, Ig, w, M); X VERBOSE_STR << "recovering B channel..." << endl; X- robertson02_getResponse( Zj, imgsB, Ib, w, M); X+ sp += robertson02_getResponse( Zj, imgsB, Ib, w, M); X+ sp /= 3; X } X break; X case DEBEVEC: X break; X+ } X+ if( sp>0 ) X+ { X+ float perc = ceilf(100.0f*sp/size); X+ VERBOSE_STR << "saturated pixels found in " << perc << "% of the image!" << endl; X } X X // save response curve to a given file END-of-graphics/pfscalibration/files/patch-src-pfshdrcalibrate.cpp echo x - graphics/pfscalibration/files/patch-src-robertson02.cpp sed 's/^X//' >graphics/pfscalibration/files/patch-src-robertson02.cpp << 'END-of-graphics/pfscalibration/files/patch-src-robertson02.cpp' X--- src/robertson02.cpp.orig Thu Mar 16 12:22:46 2006 X+++ src/robertson02.cpp Thu Jun 21 14:34:34 2007 X@@ -50,7 +50,7 @@ X float normalizeI( float* I, int M ); X X X-void robertson02_applyResponse( pfs::Array2D* xj, const ExposureList &imgs, X+int robertson02_applyResponse( pfs::Array2D* xj, const ExposureList &imgs, X const float* I, const float* w, int M ) X { X // number of exposures X@@ -59,6 +59,58 @@ X // frame size X int width = xj->getCols(); X int height = xj->getRows(); X+ X+ // number of saturated pixels X+ int saturated_pixels = 0; X+ X+ // --- anti saturation: calculate trusted camera output range X+ int minM = 0; X+ for( int m=0 ; m0 ) X+ { X+ minM = m; X+ break; X+ } X+ int maxM = M-1; X+ for( int m=M-1 ; m>=0 ; m-- ) X+ if( w[m]>0 ) X+ { X+ maxM = m; X+ break; X+ } X+ X+ // --- anti ghosting: for each image i, find images with X+ // the immediately higher and lower exposure times X+ int* i_lower = new int[N]; X+ int* i_upper = new int[N]; X+ for( int i=0 ; iti && imgs[j].titi_lower ) X+ { X+ ti_lower=imgs[j].ti; X+ i_lower[i]=j; X+ } X+ } X+ if( i_lower[i]==-1 ) X+ i_lower[i]=i; X+ if( i_upper[i]==-1 ) X+ i_upper[i]=i; X+ } X+ X X // all pixels X for( int j=0 ; jmaxM ) X+ minti = fminf(minti,ti); X+ if( mm || m_upper-1e6f ) X+ { X+ sum = I[minM]; X+ div = maxti; X+ } X+ if( div==0.0f && minti<+1e6f ) X+ { X+ sum = I[maxM]; X+ div = minti; X+ } X+ X if( div!=0.0f ) X (*xj)(j) = sum/div; X else X (*xj)(j) = 0.0f; X } X+ X+ delete[] i_lower; X+ delete[] i_upper; X+ X+ return saturated_pixels; X } X X X-void robertson02_getResponse( pfs::Array2D* xj, const ExposureList &imgs, X+int robertson02_getResponse( pfs::Array2D* xj, const ExposureList &imgs, X float* I, const float* w, int M ) X { X // number of exposures X@@ -105,6 +185,9 @@ X int width = imgs[0].yi->getCols(); X int height = imgs[0].yi->getRows(); X X+ // number of saturated pixels X+ int saturated_pixels = 0; X+ X // indexes X int i,j,m; X X@@ -160,7 +243,7 @@ X float middle_response = normalizeI( I, M ); X X // 3. Apply new response X- robertson02_applyResponse( xj, imgs, I, w, M ); X+ saturated_pixels = robertson02_applyResponse( xj, imgs, I, w, M ); X X // 4. Check stopping condition X float delta = 0.0f; X@@ -198,6 +281,8 @@ X delete[] Ip; X delete[] cardEm; X delete[] sum; X+ X+ return saturated_pixels; X } X X END-of-graphics/pfscalibration/files/patch-src-robertson02.cpp echo x - graphics/pfscalibration/files/patch-src-robertson02.h sed 's/^X//' >graphics/pfscalibration/files/patch-src-robertson02.h << 'END-of-graphics/pfscalibration/files/patch-src-robertson02.h' X--- src/robertson02.h.orig Thu Mar 16 12:22:46 2006 X+++ src/robertson02.h Thu Jun 21 14:34:34 2007 X@@ -39,8 +39,9 @@ X * @param I [out] array to put response function X * @param w weights X * @param M max camera output (no of discrete steps) X+ * @return number of saturated pixels in the HDR image (0: all OK) X */ X-void robertson02_getResponse( pfs::Array2D* xj, const ExposureList &imgs, X+int robertson02_getResponse( pfs::Array2D* xj, const ExposureList &imgs, X float* I, const float* w, int M ); X X X@@ -53,8 +54,9 @@ X * @param I camera response function (array size of M) X * @param w weighting function for camera output values (array size of M) X * @param M number of camera output levels X+ * @return number of saturated pixels in the HDR image (0: all OK) X */ X-void robertson02_applyResponse( pfs::Array2D* xj, const ExposureList &imgs, X+int robertson02_applyResponse( pfs::Array2D* xj, const ExposureList &imgs, X const float* I, const float* w, int M ); X X END-of-graphics/pfscalibration/files/patch-src-robertson02.h echo x - graphics/pfscalibration/Makefile sed 's/^X//' >graphics/pfscalibration/Makefile << 'END-of-graphics/pfscalibration/Makefile' X# New ports collection makefile for: pfscalibration X# Date created: Fri Jun 1 15:44:40 UTC 2007 X# Whom: argv[0] (Iouri V. Ivliev) X# X# $FreeBSD$ X XPORTNAME= pfscalibration XPORTVERSION= 1.3 XPORTREVISION= 1 XCATEGORIES= graphics XMASTER_SITES= SF XMASTER_SITE_SUBDIR= pfstools X XMAINTAINER= ii@any.com.ru XCOMMENT= Photometric calibration of cameras and recovery HDR images from the set of LDR exposures X XPFS_CPPFLAGS= -I${LOCALBASE}/include XPFS_LDFLAGS= -L${LOCALBASE}/lib X XGNU_CONFIGURE= yes XCONFIGURE_TARGET= --build=${MACHINE_ARCH}-portbld-freebsd${OSREL} XCONFIGURE_ENV= CPPFLAGS="${PFS_CPPFLAGS}" \ X LDFLAGS="${PFS_LDFLAGS}" XUSE_GMAKE= yes XUSE_PERL5= yes X XLIB_DEPENDS= pfs-1.2:${PORTSDIR}/graphics/pfstools X XMAN1= jpeg2hdrgen.1 \ X dcraw2hdrgen.1 \ X pfsinhdrgen.1 \ X pfshdrcalibrate.1 X X.include END-of-graphics/pfscalibration/Makefile echo x - graphics/pfscalibration/distinfo sed 's/^X//' >graphics/pfscalibration/distinfo << 'END-of-graphics/pfscalibration/distinfo' XMD5 (pfscalibration-1.3.tar.gz) = 5a08ec634cf53b105f412a826a2c2451 XSHA256 (pfscalibration-1.3.tar.gz) = 4ced5e1ff45a9e3a02592b002c008c2c974b9d80762198e71e678e4c16e1b754 XSIZE (pfscalibration-1.3.tar.gz) = 306650 END-of-graphics/pfscalibration/distinfo echo x - graphics/pfscalibration/pkg-descr sed 's/^X//' >graphics/pfscalibration/pkg-descr << 'END-of-graphics/pfscalibration/pkg-descr' XPFScalibration package provides an implementation of the Robertson Xet al. 2003 method for the photometric calibration of cameras and Xfor the recovery of high dynamic range (HDR) images from the set Xof low dynamic range (LDR) exposures. X XWWW: http://www.mpii.mpg.de/resources/hdr/calibration/pfs.html END-of-graphics/pfscalibration/pkg-descr echo x - graphics/pfscalibration/pkg-plist sed 's/^X//' >graphics/pfscalibration/pkg-plist << 'END-of-graphics/pfscalibration/pkg-plist' Xbin/pfshdrcalibrate Xbin/jpeg2hdrgen Xbin/dcraw2hdrgen Xbin/pfsinhdrgen END-of-graphics/pfscalibration/pkg-plist exit