00001 00002 00003 00004
00005 package require gfm
00006 package require image
00007 package require datareader
00008 package require display
00009
00010 namespace eval premodeler {
00011 00012 00013 00014 proc displayTrackedPointsOnSequence { engine } {
00015 set result [::premodeler::Engine_getProcessResult $engine]
00016 set dataReader [premodeler::Engine_getDataReader $engine]
00017 set sensor [premodeler::Engine_getSensorName $engine]
00018 set monoReader [datareader::DataReader_getMonoReader $dataReader $sensor]
00019 set i 0
00020 ::premodeler::displayTrackedPointsOnImage $result $monoReader $i
00021 }00022
00023 00024 00025 00026 proc displayTrackedPointsOnImage { processResult reader counter {enableClick "true"} } {
00027 if {$counter < [premodeler::sizeSequenceMR $processResult]} {
00028 set vmr [premodeler::getVMR $processResult $counter]
00029 set index [premodeler::ViewMR_vIndex_get $vmr]
00030 set mr [premodeler::ViewMR_vMatchingResult_get $vmr]
00031 set dr [gfm::MatchingResult_pointsMatch $mr]
00032 set img [datareader::MonoReader_loadImage $reader $index]
00033 display::show $img
00034 gfm::displayTrackedHarrisPoints $img $dr
00035 }
00036
00037 if $enableClick {
00038 bind .$img <ButtonPress-1> "::premodeler::displayTrackedPointsOnImage $result $reader [expr $counter + 1]"
00039 }
00040 }00041
00042 00043 00044 00045 00046 proc displayTrackedPointsOnView { engine imgIndex } {
00047 set result [::premodeler::Engine_getProcessResult $engine]
00048 set begin [premodeler::Engine_getBegin $engine]
00049 set end [premodeler::Engine_getEnd $engine]
00050 set step [premodeler::Engine_getStep $engine]
00051 if {$imgIndex <= $end} {
00052 if {$imgIndex >= [expr $begin + $step]} {
00053 if {[expr [expr $imgIndex - $begin ] % $step] == 0} {
00054 set vmr [premodeler::getVMRofImg $result $imgIndex]
00055 set mr [premodeler::ViewMR_vMatchingResult_get $vmr]
00056 set dr [gfm::MatchingResult_pointsMatch $mr]
00057 set dataReader [premodeler::Engine_getDataReader $engine]
00058 set sensor [premodeler::Engine_getSensorName $engine]
00059 set reader [datareader::DataReader_getMonoReader $dataReader $sensor]
00060 set img [datareader::MonoReader_loadImage $reader $imgIndex]
00061 display::show $img
00062 gfm::displayTrackedHarrisPoints $img $dr
00063 } else {
00064 puts "don't fit within step!"
00065 }
00066 } else {
00067 puts "prior to begin!"
00068 }
00069 } else {
00070 puts "exceeds end!"
00071 }
00072 }00073
00074 00075 00076 00077 proc displayRecognition { recognizer engine {color "green"} } {
00078 set img_file [premodeler::ObjectRecognizer_getRequestImageFileName $recognizer]
00079 set ref_img [image::Image_loadImage $img_file]
00080 set match_img_id [premodeler::ObjectRecognizer_getBestView $recognizer]
00081 set dataReader [premodeler::Engine_getDataReader $engine]
00082 set sensor [premodeler::Engine_getSensorName $engine]
00083 set reader [datareader::DataReader_getMonoReader $dataReader $sensor]
00084 set match_img [datareader::MonoReader_loadImage $reader $match_img_id]
00085 set matches [premodeler::ObjectRecognizer_getBestMatchesVector $recognizer]
00086 set result_img [premodeler::mergeImages $ref_img $match_img]
00087 display::show $result_img
00088 for {set i 0} {$i < [gfm::sizeMatchesVec $matches]} {incr i} {
00089 set hp1 [gfm::getMatchFirst [ gfm::getMatchesVec $matches $i]]
00090 set hp2 [gfm::getMatchSecond [ gfm::getMatchesVec $matches $i]]
00091 set u1 [expr round([ gfm::InterestPoint_u $hp1 ])]
00092 set v1 [expr round([ gfm::InterestPoint_v $hp1 ])]
00093 display::drawSquare $result_img $u1 $v1 5 1 $color {jafar hpm_match}
00094 display::drawText $result_img $u1 [expr $v1 - 10] "$i" $color "c" {jafar hpm_match}
00095 set u2 [expr round([ gfm::InterestPoint_u $hp2 ])]
00096 set offset [::image::CvImage_width $ref_img]
00097 set u2 [expr $u2 + $offset]
00098 set v2 [expr round([ gfm::InterestPoint_v $hp2 ])]
00099 display::drawSquare $result_img $u2 $v2 5 1 $color {jafar hpm_match}
00100 display::drawText $result_img $u2 [expr $v2 - 10] "$i" $color "c" {jafar hpm_match}
00101 display::drawLine $result_img $u1 $v1 $u2 $v2 1 "blue"
00102 }
00103 }00104
00105 }00106 package provide premodeler 0.9
00107