Program Flow
Public Class For1 Declared
Variables and Constants are set up
The video capture functions are declared
Form1 is Loaded
If a radio button had been saved from the last session to establish the video source, it is used
ListVideoSources()is called
The system scans video source drivers 0 to 9 and lists the active drivers in the videosource listbox
Previewvideo() is called
capCreateCaptureWindowA()is called
A capture window is created for the video feed
The video window is set us by calling the Sendmessage function to set variables
LoadfoundDirectory()is called
The year/month and day are established from the calendar and then used as the name of
the directory to store and retrieve images. C:\programfiles\motioncontrol\YYYYMMdd\
BoldTheCalendarDays() is called
Each day of the month are checked to see if a corresponding directory exists, and contains images.
For example, if the current month is February of 2010, the program will look for images in
20100201 for images
20100202 for images
etc, etc until it reaches folder 20100228
Each time it finds at least on image in the directory, the calendar day is marked bold
CreateDir() is called
if a directory does not exist for the current day, one is created
The program now waits for an action from the user
User selects a video source from the source list
StopPreviewWindow() is called to stop the preview window if active
The video source is set as selected
PreviewVideo(PictureBoxVideo) is called to restart the video with the new source
User presses the Start button for Record Motion
Private Sub StartButton_Click takes the click event
The directory name is set to the current date
ReplayFileCount is set to count new images and will be used for the file names
Timer 1 is initialized and sets the time between pictures
Private Sub Timer1_Tick now tells the program to take a picture on each pulse
Pictures taken during the ""Odd"" pulse are stored as BitmapCaptureImageA
Pictures taken during the ""Even"" pulse is stored as BitmapCaptureImageB
CaptureImage() is called and actually captures the images and Bitmap…A&B
SendMessage() is called to capture the image from the video and copy it to clipboard
The odd image is stored as BitmapCaptureImageA
The even image is stored as BitmapCaptureImageB
GetLines(BitmapCaptureImageA) is called to copy vertical lines of pixels from the imageA
This is done instead of coping the entire image for comparison
GetLines(BitmapCaptureImageB) is called to copy vertical lines of pixels from the imageB
GetVB() is called to to record the number of pixel changes in each vertical line.
The number of changes for each line is stored in array VBV
GetHB() can do the same for horizontal lines of pixels, but is turned off for speed
A For loop is run on VBV to see how many of the vertical lines have change since last image
More pixels than the Tolerance must have changed to be recorded as a changed line
SaveImage() is called, if the number of changed lines meets the criteria
The image is saved in a directory with the currents data name
the file name is the date and time of the image
User Selects the Forward Play Back button
ForwardButton_Click event occurs
The direction of play is set to Forward
playFile() is called
The directory name is determined from the current calendar date
The directory is opened and a filelist is created
InitializeTimer2() is called to start a timer for displaying the images
On each tick of the timer the filelist counter is incremented
DisplayPicture(ReplayFileCount, dirname) is called
The image is displayed in the picture box