home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascendMar8.tar
/
UMass
/
Epipolar
/
epiinit-rcde.lisp
< prev
next >
Wrap
Lisp/Scheme
|
1996-03-06
|
6KB
|
160 lines
;;; EPIINIT-RCDE.LISP
;;;
;;; Init epipolar matcher within RCDE
;;; to be used in conjunction with $CME/code/CME-5d/UMass/umass-system.lisp
;;;
;;; Author: Robert T. Collins
;;; Date: Apr 13, 1995
;;;
;-----------------------------------------------------------------
; (c) Copyright 1995 by The University of Massachusetts
;------------------------------------------------------------------
(in-package 'cme)
(defvar *tokenset-grid-cache* nil
"cache of grid structures for line tokensets")
(defvar *projection-fbipfile-cache* nil
"cache of ascii-fbip files for 3d-to-2d projections")
(defun get-or-make-line-grid (tokenset)
(let ((grid (second (find tokenset *tokenset-grid-cache* :key #'car))))
(unless grid
(format t "Making ISR grid structure for ~a...~%" tokenset)
(setf grid (epi::gridify-data-lines tokenset))
(push (list tokenset grid) *tokenset-grid-cache*))
grid))
(defun get-or-make-fbip-file (2dworld)
(let* ((proj (3d-to-2d-projection 2dworld))
(fbip nil)
(filename (second (find proj *projection-fbipfile-cache* :key #'car))))
(unless filename
(setf filename
(concatenate 'string
(translated-unix-path
(format nil "~a" user::*temp-directory*))
(replace-spaces-with-hyphens (string (name 2dworld)))
".ascii-fbip"))
(format t "Writing temp fbip file ~a...~%" filename)
(ecase (type-of proj)
(FAST-BLOCK-INTERPOLATION-PROJECTION
(setf fbip proj))
(4X4-COORDINATE-PROJECTION
(setf fbip nil)) ;(make-dummy-fbip-shell (base-image 2dworld) proj)))
(COMPOSITE-COORDINATE-PROJECTION
(let ((tlist (transform-list proj)))
(if (and
(typep (first tlist) '4X4-COORDINATE-TRANSFORM)
(typep (second tlist) 'FAST-BLOCK-INTERPOLATION-PROJECTION))
(let ((oldfbip (fbip (second tlist))))
(setf fbip (make-fast-block-interpolation-projection
:projection proj
:z-levels (fbip-z-levels oldfbip)
:umin (fbip-umin oldfbip)
:umax (fbip-umax oldfbip)
:vmin (fbip-vmin oldfbip)
:vmax (fbip-vmax oldfbip)
:blocks-wide (fbip-blocks-wide oldfbip)
:blocks-hi (fbip-blocks-hi oldfbip))))
(error "Can only handle composite transforms of the form (4X4-COORDINATE-TRANSFORM FAST-BLOCK-INTERPOLATION-PROJECTION)")))))
(when fbip (write-ascii-data-bip-file fbip filename))
(push (list proj filename) *projection-fbipfile-cache*))
filename))
(defun rcde-init-epi-view (2dworld &key
(require-boldt-lines (not epi::*topdown-line-finder*))
(require-view-loaded epi::*demo-mode*))
(let* ((linefs (find-fs-named 2dworld *2d-line-fsname*))
(isrobject (when linefs
(find 'ISR-LINE-TOKENSET-OBJECT (inferiors linefs)
:key #'type-of :test #'equal)))
(rcde-view (car (view-list 2dworld))))
(when (and
(or (not require-view-loaded) (and require-view-loaded rcde-view))
(or (not require-boldt-lines) (and require-boldt-lines isrobject)))
(let ((view (epi::make-view :label (name 2dworld)))
(tks (and isrobject (tokenset isrobject))))
(setf (epi::view-image view)
(ic::top-of-image-hierarchy (view-image rcde-view)))
(setf (epi::view-projection view) (3d-to-2d-projection 2dworld))
(setf (epi::view-projfile view) (get-or-make-fbip-file 2dworld))
(setf (epi::view-line-tokenset view) tks)
(setf (epi::view-line-grid view) (and tks (get-or-make-line-grid tks)))
(setf (epi::view-topdown-linelist view) nil)
(setf (epi::view-topdown-edgels view) nil)
(setf (epi::view-window view) rcde-view)
view))))
(defvar *epipolar-viewlist* nil "list of view structures for epipolar matcher")
(defun find-epi-view-for-world (2dworld)
(find (name 2dworld) *epipolar-viewlist*
:key #'epi::view-label :test #'string-equal))
(defun find-the-other-epi-views (2dworld)
(remove (name 2dworld) *epipolar-viewlist*
:key #'epi::view-label :test #'string-equal))
;;for mb1 zmin = -92.0 zmax = 146.0
(defun rcde-init-epipolar-views (3dworld)
(setf *epipolar-viewlist* nil)
(dolist (2dworld (2d-worlds 3dworld))
(let ((view (rcde-init-epi-view 2dworld)))
(when view (push view *epipolar-viewlist*))))
3dworld)
(defun rcde-init-height-histograms (zmin zmax)
(epi::set-global-height-range zmin zmax)
(epi::init-epipolar-histograms))
(defun trans-vertex-list (transform vertex-list)
(mapcar #'(lambda (vert)
(cme::bind-vertex-elements (x y)
(cme::inline-transform transform vert)
(list x y)))
vertex-list))
(defun linelist-from-2dcurve (curve)
(let* ((trans (cme::object-to-world-transform curve))
(vertexlist (la::listarray (cme::vertices curve)))
(vertices (trans-vertex-list trans vertexlist))
(n (length vertices))
(result nil))
(dotimes (i n (nreverse result))
(push (append (elt vertices i) (elt vertices (mod (+ i 1) n)))
result))))
(defun rcde-run-epipolar-matcher (2dworld curve &key (filename nil)
(endpoint-slop 1.0)(delta-theta .1)
(run-canny? epi::*topdown-line-finder*))
(let ((view1 (find-epi-view-for-world 2dworld))
(otherviews (find-the-other-epi-views 2dworld))
(linelist (linelist-from-2dcurve curve)))
(when run-canny?
(dolist (view2 otherviews)
(let ((boundingbox (epi::epipolar-search-area-bbox
view1 view2 linelist)))
(setf (epi::view-topdown-edgels view2)
(apply #'compute-2dworld-canny-edges
(epi::view-image view2)
boundingbox)))))
(let ((match (epi::epipolar-match-linelist
view1 linelist otherviews
:endpoint-slop endpoint-slop
:delta-theta delta-theta)))
(when filename
(epi::save-matches-to-file match filename))
(when run-canny?
(dolist (view2 otherviews)
(free-edgeimg (epi::view-topdown-edgels view2))))
match)))