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
/
2pt5d-lines.lisp
< prev
next >
Wrap
Lisp/Scheme
|
1996-03-06
|
6KB
|
156 lines
;;; 2pt5d-lines.lisp
;;; add height information to 2d lines to create a 2.5d line set.
;;;
;;; Author: Bob Collins Date: 7/15/95
;;; Copyright: University of Massachusetts, 1995, all rights reserved
;;;
;;; 2/21/96: BobC - changed compute-2.5d-lines to use noting-progress macros
;;;
(in-package 'epi)
(defun histogram-2.5d-line-heights (view1 x1 y1 x2 y2 view2 &rest keys)
(let ((window (view-window view2)))
(when (and *demo-mode* window)
(let ((bbox (epipolar-search-area-bbox view1 view2
(list (list x1 y1 x2 y2)))))
(activate-window window)
(cme::zoom-to-bounding-box window (car bbox) (second bbox)
(third bbox) (fourth bbox) 10)))
(apply #'histogram-line-candidates
view1 x1 y1 x2 y2 view2
:zoom nil :peak-weight? t
keys)
(when (and *demo-mode* window (eq *pause-mode* :lines))
(synch-epipolar-screen window)
(setf *pause-mode*
(if (yes-or-no-p "Pause between lines?") :lines :views)))))
(defvar *minimum-support-percentage* 0.4)
(defvar *multiple-peak-relative-support-threshold* 0.5)
(defun find-height-histogram-next-peak (histogram reference-conf
&optional (excluded-indices nil))
(multiple-value-bind (peak conf)
(hist::find-highest-peak histogram excluded-indices)
(when (and peak
(> conf *minimum-support-percentage* )
(> (/ conf reference-conf)
*multiple-peak-relative-support-threshold*))
(multiple-value-list (interpolate-peak histogram peak)))))
(defun find-height-hypotheses (histogram)
(let ((height-hypotheses nil)
(indices nil))
(do ((peak-info (find-height-histogram-next-peak
histogram
*minimum-support-percentage*)
(find-height-histogram-next-peak
histogram
(second peak-info)
indices)))
((null peak-info) (reverse height-hypotheses))
(setf indices (append indices (third peak-info)))
(push (list (car peak-info) (cadr peak-info)) height-hypotheses))))
(defun compute-2.5d-line-heights (reference-view x1 y1 x2 y2 other-view-list
&key (endpoint-slop 1.0)(delta-theta .1))
(when *demo-mode*
(let ((window (view-window reference-view)))
(activate-window window)
(cme::zoom-to-bounding-box window (min x1 x2) (min y1 y2)
(max x1 x2) (max y1 y2) 10)
(display-line window x1 y1 x2 y2 :color *match-color*
:thickness *match-thickness*)))
(clear-height-histogram *accum-histogram*)
(dolist (other-view other-view-list)
(clear-height-histogram *current-histogram*)
(histogram-2.5d-line-heights
reference-view x1 y1 x2 y2 other-view
:histogram *current-histogram*
:deltatheta delta-theta
:endpoint-slop endpoint-slop)
(add-to-height-histogram *accum-histogram* *current-histogram*)
(when *demo-mode*
(synch-epipolar-screen (view-window other-view))))
(hist::scale-histogram *accum-histogram* (/ 1.0 (length other-view-list)))
(find-height-hypotheses *accum-histogram*))
(defun compute-2.5d-lines (ref-view linelist other-views &key
(endpoint-slop 1.0)(delta-theta .1)
&aux save-pause-mode (count 0)(result-list nil))
(setf save-pause-mode *pause-mode*)
(when *topdown-line-finder*
(dolist (view2 other-views)
(let* ((coordlist (mapcan #'(lambda (line)
(multiple-value-list
(apply #'epipolar-search-area
(view-projection ref-view)
(view-projection view2)
line)))
linelist))
(minx (reduce #'min coordlist :key #'car))
(miny (reduce #'min coordlist :key #'cadr))
(maxx (reduce #'max coordlist :key #'car))
(maxy (reduce #'max coordlist :key #'cadr)))
(setf (view-topdown-edgels view2)
(cme::compute-2dworld-canny-edges
(view-image view2)
minx miny maxx maxy)))))
(ic::noting-progress ("2.5D" (length linelist) :progress-var 2.5d-progress)
(dolist (line linelist)
(let ((heights (compute-2.5d-line-heights
ref-view
(car line) (cadr line) (third line) (fourth line)
other-views
:endpoint-slop endpoint-slop
:delta-theta delta-theta)))
(if heights
(dolist (height heights)
(push (append line height) result-list))
;;otherwise include line anyways, but with zero confidence
(push (append line '(0.0 0.0)) result-list)))
(ic::note-progress (incf count) 2.5d-progress)))
(when *topdown-line-finder*
(dolist (view2 other-views)
(cme::free-edgeimg (view-topdown-edgels view2))))
(setf *pause-mode* save-pause-mode)
;;(setf *2pt5d-lines* result-list)
result-list)
(defun make-quad-from-bbox (x1 y1 x2 y2)
(list (list x1 y1) (list x1 y2) (list x2 y2) (list x2 y1)))
(defun compute-2.5d-lines-in-pane-bbox (pane bbox &key
(endpoint-slop 1.0)(delta-theta .1)
(min-support 0.5))
(setf *minimum-support-percentage* min-support)
(let* ((topview (cme::top-view pane))
(2dworld (cme::2d-world topview))
(pane-trans (cme::inverse-transform
(cme::2d-to-window-transform topview)))
(refview (cme::find-epi-view-for-world 2dworld))
(otherviews (cme::find-the-other-epi-views 2dworld))
(2dlinelist nil))
(multiple-value-bind (minx miny maxx maxy)
(apply #'cme::transform-2d-bounding-box pane-trans bbox)
(multiple-value-bind (ignore tokenset)
(cme::get-or-make-ISR-tokenset (cme::find-fs-named 2dworld
cme::*2d-line-fsname*))
ignore
(isr2::for-every-token (tok tokenset (x1 y1 x2 y2))
(let ((vx1 (isr2::value x1))
(vy1 (isr2::value y1))
(vx2 (isr2::value x2))
(vy2 (isr2::value y2)))
(unless (cme::approx-line-not-visible-p minx miny maxx maxy
vx1 vy1 vx2 vy2)
(push (list vx1 vy1 vx2 vy2) 2dlinelist))))))
(compute-2.5d-lines refview 2dlinelist otherviews
:endpoint-slop endpoint-slop
:delta-theta delta-theta)))