Changeset 379
- Timestamp:
- 12/30/07 09:06:48 (10 months ago)
- Files:
-
- trunk/FastImage/examples/cross_corr.py (modified) (3 diffs)
- trunk/FastImage/examples/simple.py (modified) (1 diff)
- trunk/FastImage/examples/test.py (modified) (1 diff)
- trunk/FastImage/motmot/FastImage/tests.py (modified) (32 diffs)
- trunk/FlyMovieFormat/scripts/fmf_batch_process.py (modified) (2 diffs)
- trunk/FlyMovieFormat/scripts/plot_timestamps.py (modified) (2 diffs)
- trunk/FlyMovieFormat/scripts/truncate_fmf.py (modified) (1 diff)
- trunk/flytrax/motmot/flytrax/trax_replay.py (modified) (3 diffs)
- trunk/fview/motmot/fview/fview_fmf_replay.py (modified) (11 diffs)
- trunk/imops/examples/simple.py (modified) (1 diff)
- trunk/motmot_utils/motmot/utils/check_new_namespace.py (modified) (1 diff)
- trunk/pycamiface/motmot/cam_iface/tests.py (modified) (3 diffs)
- trunk/realtime_image_analysis/motmot/realtime_image_analysis/tests.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/FastImage/examples/cross_corr.py
r87 r379 1 1 from __future__ import division 2 import FastImage2 import motmot.FastImage.FastImage as FastImage 3 3 import numpy 4 4 … … 91 91 print numpy.asarray(result32f) 92 92 print 93 93 94 94 if 1: 95 95 # use preallocated memory (32 bit float) … … 101 101 print numpy.asarray(pre_alloc_result_32f) 102 102 print 103 103 104 104 max_val,x,y=pre_alloc_result_32f.max_index(result_size) 105 105 print 'max_val,x,y',max_val,x,y trunk/FastImage/examples/simple.py
r87 r379 1 1 from __future__ import division 2 import FastImage2 import motmot.FastImage.FastImage as FastImage 3 3 import numpy 4 4 trunk/FastImage/examples/test.py
r87 r379 1 import FastImage as fi1 import motmot.FastImage.FastImage as fi 2 2 3 3 width = 10 trunk/FastImage/motmot/FastImage/tests.py
r361 r379 23 23 self.assert_(s1 is not s2) 24 24 self.assert_(s1 != s3) 25 25 26 26 class TestFastImageBase(unittest.TestCase): 27 27 def setUp(self): … … 30 30 self.ar_dtypes = [nx.uint8, 31 31 nx.float32] 32 32 33 33 def test_roi(self): 34 34 sz = fi.Size(20,10) … … 73 73 arA = nx.zeros((size.h, size.w),ar_dtype) 74 74 self.assert_( nx.allclose(arA, nx.asarray(imA))) 75 75 76 76 def test_getitem(self): 77 77 size = fi.Size(20,10) … … 96 96 def test_32f_copy(self): 97 97 sz = fi.Size(20,10) 98 98 99 99 imA=fi.FastImage8u(sz) 100 100 imA.set_val(87,sz) 101 101 102 102 imB=fi.FastImage32f(sz) 103 103 imA.get_32f_copy_put(imB,sz) … … 111 111 B = 38 112 112 sz = fi.Size(33,323) 113 113 114 114 imA=fi.FastImage8u(sz) 115 115 imA.set_val(A,sz) … … 120 120 imC=fi.FastImage8u(sz) 121 121 imA.get_absdiff_put(imB,imC,sz) 122 122 123 123 arA = A*nx.ones((sz.h, sz.w),nx.int16) 124 124 arB = B*nx.ones((sz.h, sz.w),nx.int16) 125 125 arC = abs(arA - arB) 126 126 self.assert_( nx.allclose(arC, nx.asarray(imC))) 127 127 128 128 def test_absdiff2(self): 129 129 … … 131 131 B = 38 132 132 sz = fi.Size(656,491) 133 133 134 134 imA=fi.FastImage8u(sz) 135 135 imA.set_val(A,sz) … … 140 140 imC=fi.FastImage8u(sz) 141 141 imA.get_absdiff_put(imB,imC,sz) 142 142 143 143 arA = A*nx.ones((sz.h, sz.w),nx.int16) 144 144 arB = B*nx.ones((sz.h, sz.w),nx.int16) 145 145 arC = abs(arA - arB) 146 146 self.assert_( nx.allclose(arC, nx.asarray(imC))) 147 147 148 148 def test_sub(self): 149 149 … … 151 151 B = 38 152 152 sz = fi.Size(656,491) 153 153 154 154 imA=fi.FastImage8u(sz) 155 155 imA.set_val(A,sz) … … 158 158 imB.set_val(B,sz) 159 159 160 imC=fi.FastImage8u(sz) 160 imC=fi.FastImage8u(sz) 161 161 imA.get_sub_put(imB,imC,sz) # imC = imA - imB 162 163 imD=fi.FastImage8u(sz) 162 163 imD=fi.FastImage8u(sz) 164 164 imB.get_sub_put(imA,imD,sz) # imD = imB - im A 165 165 … … 174 174 def test_iconvert(self): 175 175 sz = fi.Size(2,2) 176 176 177 177 imB=fi.FastImage32f(sz) 178 178 imB.set_val(3.2,sz) … … 186 186 self.assert_( nx.allclose(arA, nx.asarray(imA))) 187 187 self.assert_( nx.allclose(arB, nx.asarray(imB))) 188 188 189 189 class TestFastImage32f(unittest.TestCase): 190 190 def test_roi(self): 191 191 sz = fi.Size(20,10) 192 192 193 193 imA=fi.FastImage32f(sz) 194 194 imA.set_val(87,sz) … … 199 199 imB=imA.roi(left,bottom,onepix) 200 200 imB.set_val(12,onepix) 201 201 202 202 arA = 87*nx.ones((sz.h, sz.w),nx.float32) 203 203 arA[bottom,left]=12 204 204 self.assert_( nx.allclose(arA, nx.asarray(imA))) 205 205 206 206 def test_add_weighted_8u(self): 207 207 … … 210 210 alpha = 0.3 211 211 sz = fi.Size(20,10) 212 212 213 213 imA=fi.FastImage32f(sz) 214 214 imA.set_val(A,sz) … … 223 223 arA = arA*(1.0-alpha) + arB*alpha 224 224 self.assert_( nx.allclose(arA, nx.asarray(imA))) 225 225 226 226 def test_add_weighted_32f(self): 227 227 … … 230 230 alpha = 0.3 231 231 sz = fi.Size(33,33) 232 232 233 233 imA=fi.FastImage32f(sz) 234 234 imA.set_val(A,sz) … … 247 247 A = 32.2 248 248 sz = fi.Size(5,5) 249 249 250 250 imA=fi.FastImage32f(sz) 251 251 imA.set_val(A,sz) … … 258 258 arC=(arA**8).astype(nx.float32) 259 259 self.assert_( nx.allclose(arC, nx.asarray(imC))) 260 260 261 261 def test_sqrt(self): 262 262 A = 32.2 263 263 sz = fi.Size(5,245) 264 264 265 265 imA=fi.FastImage32f(sz) 266 266 imA.set_val(A,sz) … … 276 276 B = 82 277 277 sz = fi.Size(63,33) 278 278 279 279 imA=fi.FastImage32f(sz) 280 280 imA.set_val(A,sz) … … 294 294 B = 3854.2 295 295 sz = fi.Size(33,63) 296 296 297 297 imA=fi.FastImage32f(sz) 298 298 imA.set_val(A,sz) … … 307 307 self.assert_( nx.allclose(arA, nx.asarray(imA))) 308 308 309 309 310 310 def test_subtract1(self): 311 311 … … 313 313 B = 3854.2 314 314 sz = fi.Size(33,323) 315 315 316 316 imA=fi.FastImage32f(sz) 317 317 imA.set_val(A,sz) … … 321 321 322 322 imA.toself_subtract(imB,sz) 323 323 324 324 arA = A*nx.ones((sz.h, sz.w),nx.float32) 325 325 arB = B*nx.ones((sz.h, sz.w),nx.float32) 326 326 arA = arA - arB 327 327 self.assert_( nx.allclose(arA, nx.asarray(imA))) 328 328 329 329 def test_subtract2(self): 330 330 … … 332 332 B = 3854.2 333 333 sz = fi.Size(33,323) 334 334 335 335 imA=fi.FastImage32f(sz) 336 336 imA.set_val(A,sz) … … 340 340 341 341 imC=imA.get_subtracted(imB,sz) 342 342 343 343 arA = A*nx.ones((sz.h, sz.w),nx.float32) 344 344 arB = B*nx.ones((sz.h, sz.w),nx.float32) … … 351 351 B = 3854.2 352 352 sz = fi.Size(33,323) 353 353 354 354 imA=fi.FastImage32f(sz) 355 355 imA.set_val(A,sz) … … 360 360 imC=fi.FastImage32f(sz) 361 361 imA.get_subtracted_put(imB,imC,sz) 362 362 363 363 arA = A*nx.ones((sz.h, sz.w),nx.float32) 364 364 arB = B*nx.ones((sz.h, sz.w),nx.float32) 365 365 arC = arA - arB 366 366 self.assert_( nx.allclose(arC, nx.asarray(imC))) 367 367 368 368 def test_from_nx1(self): 369 369 … … 371 371 sz = fi.Size(33,323) 372 372 arA = nx.array(A,nx.float32)*nx.ones((sz.h, sz.w),nx.float32) 373 373 374 374 imA=fi.asfastimage(arA) 375 375 arA[1,3:40] = 3024.03 … … 382 382 sz = fi.Size(33,323) 383 383 arA = nx.array(A,nx.float32)*nx.ones((sz.h, sz.w),nx.float32) 384 384 385 385 imA=fi.copy(arA) 386 386 arA[1,3:40] = 3024.03 … … 390 390 def test_ipow(self): 391 391 sz = fi.Size(2,2) 392 392 393 393 imA=fi.FastImage32f(sz) 394 394 imA.set_val(2,sz) … … 401 401 arA **= 0.5 402 402 self.assert_( nx.allclose(arA, nx.asarray(imA))) 403 403 404 404 def test_iadd(self): 405 405 sz = fi.Size(2,2) 406 406 407 407 imA=fi.FastImage32f(sz) 408 408 imA.set_val(2,sz) … … 415 415 def test_iconvert(self): 416 416 sz = fi.Size(2,2) 417 417 418 418 imA=fi.FastImage32f(sz) 419 419 trunk/FlyMovieFormat/scripts/fmf_batch_process.py
r1 r379 1 1 #!/usr/bin/env python 2 2 import glob 3 import FlyMovieFormat3 import motmot.FlyMovieFormat.FlyMovieFormat as FlyMovieFormat 4 4 5 5 # change this to current filenames … … 30 30 print '%(input_filename)s (%(in_width)dx%(in_height)d, '\ 31 31 '%(fmax)d frames) ->'%locals() 32 32 33 33 print ' %(output_filename)s (%(width)dx%(height)d, '\ 34 34 '%(n_output_frames)d frames) : '%locals(), trunk/FlyMovieFormat/scripts/plot_timestamps.py
r1 r379 1 1 #!/usr/bin/env python 2 2 3 import FlyMovieFormat3 import motmot.FlyMovieFormat.FlyMovieFormat as FlyMovieFormat 4 4 from pylab import * 5 5 import sys … … 10 10 n_frames = fly_movie.get_n_frames() 11 11 timestamps = numarray.zeros((n_frames,),type=numarray.Float64) 12 for i in xrange(n_frames): 12 for i in xrange(n_frames): 13 13 timestamps[i]=fly_movie.get_next_timestamp() 14 14 diff = (timestamps[1:]-timestamps[:-1])*1000.0 trunk/FlyMovieFormat/scripts/truncate_fmf.py
r1 r379 1 1 #!/usr/bin/env python 2 import FlyMovieFormat2 import motmot.FlyMovieFormat.FlyMovieFormat as FlyMovieFormat 3 3 4 4 input_filename = '20050304_1834.fmf' trunk/flytrax/motmot/flytrax/trax_replay.py
r294 r379 1 import pkg_resources 1 2 import flytrax 2 3 try: … … 4 5 except ImportError: 5 6 import traxio 6 import FlyMovieFormat7 import motmot.FlyMovieFormat.FlyMovieFormat as FlyMovieFormat 7 8 import numpy 8 import FastImage9 import motmot.FastImage.FastImage as FastImage 9 10 import wx 10 11 import wx.xrc as xrc 11 import pkg_resources12 import wxglvideo13 12 import time, Queue, threading, os 14 13 import sys 14 import motmot.fview.fview_video as video_module 15 15 16 16 RESFILE = pkg_resources.resource_filename(__name__,"trax_replay.xrc") # trigger extraction … … 40 40 main_display_panel.SetSizer(box) 41 41 42 self.cam_image_canvas = wxglvideo.DynamicImageCanvas(main_display_panel,-1)42 self.cam_image_canvas = video_module.DynamicImageCanvas(main_display_panel,-1) 43 43 self.cam_image_canvas.x_border_pixels = 0 44 44 self.cam_image_canvas.y_border_pixels = 0 trunk/fview/motmot/fview/fview_fmf_replay.py
r177 r379 1 import FlyMovieFormat 1 import pkg_resources 2 import motmot.FlyMovieFormat.FlyMovieFormat as FlyMovieFormat 2 3 import numpy 3 4 import wx 4 5 import wx.xrc as xrc 5 import pkg_resources 6 import wxglvideo 6 import motmot.wxglvideo.wxglvideo as wxglvideo 7 7 import time, Queue, threading, os 8 8 import sys … … 15 15 16 16 class ReplayApp(wx.App): 17 17 18 18 def OnInit(self,*args,**kw): 19 19 wx.InitAllImageHandlers() 20 20 self.frame = RES.LoadFrame(None,"FVIEW_FMF_REPLAY_FRAME") # make frame main panel 21 21 self.frame.Show() 22 22 23 23 self.plugins, plugin_dict = plugin_manager.load_plugins(self.frame) 24 24 … … 53 53 self.tracker = self.plugins[0] # XXX have better selection mechanism 54 54 self.tracker.get_frame().Show() 55 55 56 56 wx.EVT_CLOSE(self.tracker.get_frame(),self.OnTrackerWindowClose) 57 57 … … 75 75 except Queue.Empty: 76 76 pass 77 77 78 78 ## if tup is not None: 79 79 ## im, points, linesegs = tup … … 85 85 ## linesegs=linesegs, 86 86 ## ) 87 87 88 88 def OnLoadFmf(self,event): 89 89 doit=False … … 101 101 return 102 102 self.load_fmf(fmf_filename) 103 103 104 104 def load_fmf(self,fmf_filename): 105 105 fmf = FlyMovieFormat.FlyMovie(fmf_filename)#, check_integrity=True) … … 108 108 format=fmf.get_format() 109 109 bg_image,timestamp0 = fmf.get_frame(0) 110 110 111 111 self.buf_allocator = None 112 112 if hasattr(self.tracker,'get_buffer_allocator'): 113 113 self.buf_allocator = self.tracker.get_buffer_allocator(cam_id) 114 114 115 115 self.tracker.camera_starting_notification(cam_id, 116 116 pixel_format=format, 117 117 max_width=bg_image.shape[1], 118 118 max_height=bg_image.shape[0]) 119 119 120 120 # save data for processing 121 121 self.loaded_fmf = dict( fmf=fmf, … … 139 139 ) 140 140 self.statusbar.SetStatusText('%s loaded'%(os.path.split(fmf_filename)[1],),0) 141 141 142 142 def OnTrackerWindowClose(self,event): 143 143 pass # don't close window (pointless in trax_replay) 144 144 145 145 def OnPlayFrames(self,event): 146 146 if self.loaded_fmf is None: … … 184 184 for y in range(h): 185 185 npy_buf[y,:iw] = fullsize_image[y,:] 186 186 187 187 points,linesegs = tracker.process_frame(cam_id, 188 188 buf, … … 197 197 finally: 198 198 playing.clear() 199 199 200 200 def main(): 201 201 app = ReplayApp(0) … … 204 204 app.load_fmf(fmf_filename) 205 205 app.MainLoop() 206 206 207 207 if app.loaded_fmf is not None: 208 208 app.tracker.quit() trunk/imops/examples/simple.py
r1 r379 1 1 # show mono16 format logic 2 2 import numpy 3 import imops3 import motmot.imops.imops as imops 4 4 5 5 h = 2 trunk/motmot_utils/motmot/utils/check_new_namespace.py
r377 r379 12 12 old_top_level_modules = ['motmot_utils', 13 13 'cam_iface', 14 'cam_iface_ctypes',15 14 'FastImage', 16 15 'fview_UDP_logger', trunk/pycamiface/motmot/cam_iface/tests.py
r240 r379 4 4 5 5 if sys.platform.startswith('linux'): 6 import cam_iface._cam_iface_shm as cishm6 import motmot.cam_iface._cam_iface_shm as cishm 7 7 8 8 class TestWrapper(unittest.TestCase): … … 15 15 16 16 def _get_cam_iface(self): 17 import cam_iface_ctypes as cam_iface 17 import cam_iface_ctypes as cam_iface # relative import 18 18 return cam_iface 19 19 20 20 def _get_cam(self,device_num=0): 21 21 cam_iface = self._get_cam_iface() … … 82 82 assert numpy.allclose( result_preallocated, fake_image ) 83 83 assert result_preallocated2 is result_preallocated 84 84 85 85 def get_test_suite(): 86 86 suites = [ trunk/realtime_image_analysis/motmot/realtime_image_analysis/tests.py
r165 r379 1 1 import unittest 2 import realtime_image_analysis as ria3 import FastImage2 import motmot.realtime_image_analysis.realtime_image_analysis as ria 3 import motmot.FastImage.FastImage as FastImage 4 4 import numpy 5 5 … … 21 21 roi_im=FastImage.FastImage8u(sz) 22 22 self.ra.do_work(roi_im,timestamp,framenumber,use_roi2,use_cmp) 23 23 24 24 def test_basic_roi2(self): 25 25 timestamp = 0.0 … … 39 39 roi_im=FastImage.FastImage8u(sz) 40 40 self.ra.do_work(roi_im,timestamp,framenumber,use_roi2,use_cmp) 41 41 42 42 def test_variance_roi2(self): 43 43 timestamp = 0.0
