00001 00002
00003 package require image
00004 package require gfm
00005
00006 namespace eval gfm {
00007 proc computeGroupsMatch {
00008 {fileName1}
00009 {fileName2}
00010 {reduction 2}
00011 {scale 1}
00012 {desiredNb 1000}
00013 {threshold 3.0}
00014 {doDisplay true}
00015 } {
00016 global ref match
00017 set ref [image::JfrImage_loadImage $fileName1]
00018 set match [image::JfrImage_loadImage $fileName2]
00019
00020 if {$reduction==1} {
00021 set ref_r $ref
00022 set match_r $match
00023 } else {
00024 # resize the ref image
00025 set ref_r [image::new_JfrImage \
00026 [expr round([$ref getWidth]/$reduction)] \
00027 [expr round([$ref getHeight]/$reduction)] \
00028 [$ref getDepth] [$ref getnChannels]]
00029 $ref resize $ref_r
00030
00031 # resize the match image
00032 set match_r [image::new_JfrImage \
00033 [expr round([$match getWidth]/$reduction)] \
00034 [expr round([$match getHeight]/$reduction)] \
00035 [$match getDepth] [$match getnChannels]]
00036 $match resize $match_r
00037 }
00038
00039 set harrisdetector [gfm::new_HarrisDetector $scale 1.0 2.0 $::gfm::HarrisDetector_HS_EIGEN $threshold "false" $desiredNb]
00040 if {$scale==1} {
00041 set sndharrisdetector $harrisdetector
00042 } else {
00043 set sndharrisdetector [gfm::new_HarrisDetector $scale 1.0 2.0 $::gfm::HarrisDetector_HS_EIGEN $threshold "false" $desiredNb]
00044 }
00045 00046 set groupsize 5
00047 set minimalgroupsize 2
00048 set distance 20.0
00049 set closeness 0.6
00050 set weakcloseness 0.6
00051 set distinguability 0.1
00052 set rotationTolerance 0.2
00053 set scaleTolerance 10000.0
00054 set distanceTolerance 10.0
00055 set rotationDifferenceWithMedian 0.4
00056 set thresholdofenoughtgroup 0.333
00057 set groupsmatcher [gfm::new_GroupsMatcher 100000 100000 $groupsize $minimalgroupsize $distance $closeness $weakcloseness $distinguability $rotationTolerance $scaleTolerance $distanceTolerance $rotationDifferenceWithMedian $thresholdofenoughtgroup ]
00058 kernel::tic
00059 set engine [gfm::new_Engine $harrisdetector $groupsmatcher $sndharrisdetector]
00060 set result [gfm::Engine_computeMatch $engine $ref_r $match_r ]
00061 putsDbg "Time to match: [kernel::toc] ms"
00062 putsDbg "Number of matches: [$result nbMatches]"
00063 if {$doDisplay } {
00064 package require display
00065 display::show $ref_r "ref"
00066 displayHarrisPoints $ref_r [Result_points_ref_get $result ] true
00067 display::show $match_r "match"
00068 displayHarrisPoints $match_r [Result_points_match_get $result ] true
00069 displayMatch $ref_r $match_r [Result_matches_get $result ] true
00070 }
00071 }00072
00073 }00074
00075 package provide gfm 0.4