Jafar
|
00001 # $Id$ # 00002 00003 namespace eval image { 00004 00005 variable capture 00006 variable captureLoopId 00007 variable imageGray 00008 variable lkTracker 00009 variable doInit "false" 00010 00011 proc liveDemoLKTracker { {cameraIndex 0} } { 00012 set w ".lkTraker" 00013 toplevel $w 00014 wm title $w "LK tracker" 00015 00016 button $w.start -text "start" -command "::image::liveDemoLKTrackerStart $cameraIndex" 00017 button $w.stop -text "stop" -command "::image::liveDemoLKTrackerStop" 00018 button $w.init -text "init" -command "set ::image::doInit true" 00019 grid $w.start 00020 grid $w.stop 00021 grid $w.init 00022 } 00023 00024 proc liveDemoLKTrackerStart { {cameraIndex 0} } { 00025 variable capture 00026 variable captureLoopId 00027 variable imageGray 00028 variable lkTracker 00029 variable doInit 00030 00031 package require display 00032 00033 set capture [image::new_Capture $cameraIndex] 00034 set image [$capture image] 00035 set imageGray [image::new_Image [$image width] [$image height] $::image::IPL_DEPTH_8U $::image::JfrImage_CS_GRAY] 00036 $image convertColorMode $imageGray 00037 00038 set lkTracker [image::new_LKTracker] 00039 set doInit "true" 00040 00041 display::show $imageGray 00042 00043 set captureLoopId [after 100 ::image::liveDemoLKTrackerRefresh] 00044 } 00045 00046 proc liveDemoLKTrackerRefresh {} { 00047 variable capture 00048 variable captureLoopId 00049 variable imageGray 00050 variable lkTracker 00051 variable doInit 00052 00053 $capture grabFrame 00054 [$capture image] convertColorMode $imageGray 00055 00056 if {$doInit} { 00057 $lkTracker init $imageGray 00058 set doInit "false" 00059 } else { 00060 $lkTracker track $imageGray 00061 } 00062 00063 display::clearOverlay $imageGray 00064 display::refresh $imageGray 00065 image::lkTrackerDisplayPointsCur $imageGray $lkTracker 00066 00067 set captureLoopId [after 100 ::image::liveDemoLKTrackerRefresh] 00068 } 00069 00070 proc liveDemoLKTrackerStop {} { 00071 variable capture 00072 variable captureLoopId 00073 variable imageGray 00074 variable lkTracker 00075 00076 after cancel $captureLoopId 00077 display::destroy $imageGray 00078 image::delete_Image $imageGray 00079 image::delete_Capture $capture 00080 image::delete_LKTracker $lkTracker 00081 } 00082 00083 } 00084 00085 package provide image 2.0
Generated on Wed Oct 15 2014 00:37:21 for Jafar by doxygen 1.7.6.1 |