program TimeLapse ; { Timed frame aquisition to disk } { Created by Digital Optics, March 2000 } { IMPORTANT: You MUST change the sDir constant below before using this module. It indicates where captured frames should be stored. HOW TO USE: This module creates a time lapse image capture toolbar that enables the user to capture images at a regular interval and automatically save them to disk. The last image captured is displayed on screen in an image window. The user can trigger an immediate capture at any time by simply pressing any key (other than Escape which is used to stop the time lapse capture). The module maintains a log file which records the file name and capture time for every frame. This log is saved when the capture sequence is stopped. This module is written for video frame grabber capture but can be readily converted to PVCAM operations by making the changes indicated by comments in the code below. } toolbar 'Time Lapse' ; const nDev = 0 ; // video device index sDir = 'C:\Documents\Images' ; // default save folder (can be changed by user) sName = 'Frame' ; // base name for saved files var Period ; // milliseconds between frames nFrames ; // total frames captured Ed ; dx,dy ; function ZeroPad( s,n ) ; var i,z ; begin z := '' ; for i := Length( s ) + 1 to n do z := z + '0' ; ZeroPad := z + s ; end; procedure SetPeriod ; button btn_Stopwatch,'Set period' ; { Change the inter-frame period } begin GetNumber( 'Enter the frame period (ms)',Period ) ; end; { SetPeriod } procedure Snap ; button btn_Camera,'Start frame capture' ; { Start snapping } var Display ; // display image Image1 ; // captured frame Name ; h,m,s,ms ; begin { init } ClearKeys ; vidSelectDevice( nDev ) ; // replace with pvcSelectCamera for PVCAM { set up display window } Display := CreateImage( vidGetImageType,vidGetXSize,vidGetYSize ) ; // modify for PVCAM Show( Display,'Display' ) ; SetWindowPos( Display,20,20 ) ; repeat { capture video image } StartClock ; GetTime( h,m,s,ms ) ; Image1 := vidCapture ; // replace with pvcCapture for PVCAM Display := Image1 ; { save to disk } nFrames := nFrames + 1 ; Name := Str( sName,nFrames:1,'.tif' ) ; Save( Image1,Name ) ; { status } WriteStatus( 'Frame: ',nFrames:4,' Press ESC to quit' ) ; writeln( Ed,Name,chr(9),chr(9),ZeroPad( Str( h:1 ),2 ),':',ZeroPad( Str( m:1 ),2 ),':',ZeroPad( Str( s+(single(ms)/1000):1:3 ),6 ) ) ; { wait for next frame time } repeat until ( Clock >= Period ) or KeyPressed ; until ReadKey = vk_Escape ; { clean up } Save( Ed,'Log.txt' ) ; Hide( Display ) ; WriteStatus( 'Frame capture stopped' ) ; end; { Snap } begin { init } vidSelectDevice( 0 ) ; SetDir( sDir ) ; Period := 5000 ; nFrames := 0 ; { create log file } GetDesktopSize( dx,dy ) ; Ed := CreateEditor( 'Log',dx-276,20,dx-20,dy-20 ) ; end.