00001 package require image
00002 package require display
00003 package require gfm
00004
00005 namespace eval sift {
00006 proc points2 { fileName {reduction 2}} {
00007
00008
00009 set image [image::Image_loadImage $fileName]
00010 if {$reduction==1} {
00011 set image_r $image
00012 } else {
00013 # resize the image
00014 set image_r [image::Image_resize $image [expr 1.0 / $reduction ] ]
00015 }
00016
00017 00018 kernel::tic;
00019 set detector [sift::new_SiftDetector ]
00020 set points [sift::SiftDetector_detectIn $detector $image_r]
00021 display::show $image_r
00022 gfm::displayHarrisPoints $image_r $points
00023
00024 }00025
00026 proc points {image {siftScale 0.5} {displayScale 0.5}} {
00027 00028
00029 set pointsVec [sift::createSiftPointsVector]
00030 sift::demoWrapper $image $siftScale $pointsVec
00031 putsDbg "Nb points: [sift::sizeSiftPointsVector $pointsVec]"
00032
00033 set imFullSize [image::JfrImage_loadImage $image]
00034 set imResized [$imFullSize resize $displayScale]
00035 image::delete_JfrImage $imFullSize
00036 display::show $imResized
00037 image::delete_JfrImage $imResized
00038
00039 sift::displayPoints $imResized $pointsVec $siftScale $displayScale
00040 }00041
00042 proc match {image1 image2 {siftScale 0.5} {displayScale 0.5} } {
00043 00044 00045 set pointsVec1 [sift::createSiftPointsVector]
00046 set pointsVec2 [sift::createSiftPointsVector]
00047
00048
00049 sift::demoWrapper $image1 $siftScale $pointsVec1
00050 sift::demoWrapper $image2 $siftScale $pointsVec2
00051
00052 set imFullSize [image::JfrImage_loadImage $image1]
00053 set imResized1 [$imFullSize resize $displayScale]
00054 image::delete_JfrImage $imFullSize
00055 display::show $imResized1 "image 1"
00056 sift::displayPoints $imResized1 $pointsVec1 $siftScale $displayScale
00057
00058 set imFullSize [image::JfrImage_loadImage $image2]
00059 set imResized2 [$imFullSize resize $displayScale]
00060 image::delete_JfrImage $imFullSize
00061 display::show $imResized2 "image 2"
00062 sift::displayPoints $imResized2 $pointsVec2 $siftScale $displayScale
00063
00064 set db [sift::new_DataBase]
00065 $db processPoints $pointsVec1 1
00066 $db processPoints $pointsVec2 0
00067
00068 displayIds $imResized1 $pointsVec1 $siftScale $displayScale
00069 displayIds $imResized2 $pointsVec2 $siftScale $displayScale
00070
00071 }00072
00073 proc displayPoints {image pointsVec siftScale displayScale {color "red"}} {
00074 set scale [expr $displayScale/$siftScale]
00075 for {set i 0} {$i < [sizeSiftPointsVector $pointsVec]} {incr i} {
00076 set pt [sift::getSiftPointsVector $pointsVec $i]
00077 # putsDbg [sift::print $pt]
00078 display::drawCross $image [expr [$pt cget -u]*$scale] [expr [$pt cget -v]*$scale] 3 1 $color {jafar sift_point}
00079 }
00080 }00081
00082 proc displayIds {image pointsVec siftScale displayScale {color "green"}} {
00083 set scale [expr $displayScale/$siftScale]
00084 for {set i 0} {$i < [sizeSiftPointsVector $pointsVec]} {incr i} {
00085 set pt [sift::getSiftPointsVector $pointsVec $i]
00086 if {[$pt cget -id] != $::sift::DBKey_NoId} {
00087 display::drawText $image [expr [$pt cget -u]*$scale-8] [expr [$pt cget -v]*$scale] "[$pt cget -id]" $color "c" {jafar sift_id}
00088 display::drawSquare $image [expr [$pt cget -u]*$scale] [expr [$pt cget -v]*$scale] 5 1 $color {jafar sift_id}
00089 }
00090 }
00091 }00092
00093 }00094
00095 package provide sift 0.2