How do I capture a video frame when my serial port tells me to?
January 18, 2007 4:26 AM Subscribe
How do I grab a video frame when a specific string is received through a serial port?
I've got a video feed which auto-cycles through a list of cameras and I'll need a video capture card to get the video into my PC.
When the feed switches to a new camera, a message is received on my RS232 port telling me stuff about the current camera. How can I grab a jpg from the video capture card when the RS232 message meets certain criteria?
I'm willing to write a small Java app if any cards can be controlled by Java...
I've got a video feed which auto-cycles through a list of cameras and I'll need a video capture card to get the video into my PC.
When the feed switches to a new camera, a message is received on my RS232 port telling me stuff about the current camera. How can I grab a jpg from the video capture card when the RS232 message meets certain criteria?
I'm willing to write a small Java app if any cards can be controlled by Java...
Response by poster: [STC]C[cam_num]P[preset][ETX][BCC]
STC = Start of message header
cam_num = camera number (3 ASCII digits)
preset = preset number (3 ASCII digits)
ETX = end of message
BCC = exclusive-OR of all characters after STC up to and including ETX.
Scenario would be:
Wait until above message is received from serial port,
Look at the camera number / preset and if they match specific values then grab a frame and write to jpeg file and name the file with date/time/camera_num/preset_num.
posted by DZ-015 at 4:54 AM on January 18, 2007
STC = Start of message header
cam_num = camera number (3 ASCII digits)
preset = preset number (3 ASCII digits)
ETX = end of message
BCC = exclusive-OR of all characters after STC up to and including ETX.
Scenario would be:
Wait until above message is received from serial port,
Look at the camera number / preset and if they match specific values then grab a frame and write to jpeg file and name the file with date/time/camera_num/preset_num.
posted by DZ-015 at 4:54 AM on January 18, 2007
If that were my project, the first thing I'd try is installing something like Simple Webcam Capture, and driving it with a .cmd script that looked something like
posted by flabdablet at 6:50 AM on January 18, 2007
set folder=C:/path/to/output/folder
for /f (tokens=1-3 delims=CP) %%A in (COM1) do call :capture %%B %%C
goto :eof
:capture
for /f "tokens=1-6 delims=:/- " %%A in ("%DATE% %TIME%") do set timestamp=%%c-%%b-%%a-%%d-%%e-%%f
set filename=%folder%/%timestamp%-%1-%2.jpg
:: now invoke Simple Webcam Capture with appropriate arguments
posted by flabdablet at 6:50 AM on January 18, 2007
You didn't say what platform you're on, but if it's windows, this could be accomplished using DirectShow. I've worked with capture devices (really just a webcam) somewhat using DirectShow.Net and could send some more info\sample code your way if you're interested. E-mail is in the profile.
posted by !Jim at 8:57 AM on January 18, 2007
posted by !Jim at 8:57 AM on January 18, 2007
Are you married to a specific platform? I wrote a small app in Perl many moons ago that grabbed a frame periodically from a framebuffer device on Linux (see the video for linux stuff) but it could have just as easily triggered on a serial port as a timer.
As I recall I simply used `` to exec a command line video for windows command to capture a frame. I did some post-processing to determine if the frame was different than the previous frame and deleted identical ones but again, you can do what you like.
I offer this suggestion because it's unclear to me from your java comment if that's a language you're comfortable with or one you're willing to slog through.
posted by phearlez at 2:54 PM on January 18, 2007
As I recall I simply used `` to exec a command line video for windows command to capture a frame. I did some post-processing to determine if the frame was different than the previous frame and deleted identical ones but again, you can do what you like.
I offer this suggestion because it's unclear to me from your java comment if that's a language you're comfortable with or one you're willing to slog through.
posted by phearlez at 2:54 PM on January 18, 2007
Response by poster: I am tied to Windows XP Pro and Java.
posted by DZ-015 at 4:13 AM on January 19, 2007
posted by DZ-015 at 4:13 AM on January 19, 2007
This thread is closed to new comments.
posted by flabdablet at 4:35 AM on January 18, 2007