I'm just turning it on and capturing the video stream, but I'm doing something wrong, because all my images have very squirrley color bits. I'm pretty sure I'm not doing something with a color palette, but I can't find ANY documentation anywhere on how to process the videostream data. This is my resulting image:
Here are my variables:
Code: Select all
Structure BitMapImage
*bitmapdata
*bitmapdataOffset
dwSize.i
EndStructure
Global NewList myImages.BitMapImage()
Global videoBMI.BITMAPINFO
Code: Select all
hWndMain = OpenWindow(0, 0, 0, 700, 500, "WebCamTest", #PB_Window_SystemMenu)
hDcMain = GetDC_(hWndMain)
hWebCam = capCreateCaptureWindowA("", #WS_CHILD, 10, 10, 640, 480, hWndMain, 0)
myCapParams.CAPTUREPARAMS
With myCapParams
\AVStreamMaster = #Null
\dwAudioBufferSize = #Null
\dwIndexSize = 0; Default
\dwMCIStartTime = #Null
\dwMCIStopTime = #Null
\dwRequestMicroSecPerFrame = 66667
\fAbortLeftMouse = #True
\fAbortRightMouse = #True
\fCaptureAudio = #False
\fDisableWriteCache = #Null
\fLimitEnabled = #False
\fMakeUserHitOKToCapture = 0
\fMCIControl = #False
\fStepCaptureAt2x = #False
\fStepMCIDevice = #Null
\fUsingDOSMemory = #Null
\fYield = 1
\vKeyAbort = #VK_ESCAPE
\wChunkGranularity = 0
\wNumAudioRequested = #Null
\wNumVideoRequested = #Null
\wPercentDropForError = 50
\wStepCaptureAverageFrames = 5 ;Samples to average for a frame
\wTimeLimit = #Null
EndWith
SendMessage_(hWebcam, #WM_CAP_DRIVER_CONNECT, 0 , 0)
SendMessage_(hWebCam, #WM_CAP_GET_VIDEOFORMAT, SizeOf(BITMAPINFO), @videoBMI)
SendMessage_(hWebCam, #WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, @VideoStreamCallBack())
SendMessage_(hWebCam, #WM_CAP_SET_CALLBACK_YIELD, 0, @CaptureYield())
SendMessage_(hWebCam, #WM_CAP_SET_SEQUENCE_SETUP, SizeOf(CAPTUREPARAMS), @myCapParams)
SendMessage_(hWebCam, #WM_CAP_SEQUENCE_NOFILE, 0, 0)
Debug "Images Captured: " + Str(ListSize(myImages()))
SendMessage_(hWebcam, #WM_CAP_DRIVER_DISCONNECT, 0, 0)
ImageGadget(0, 10, 10, 640, 480, 0)
ResetList(myImages())
While NextElement(myImages())
WindowEvent()
OpenFile(1, "c:\users\justin\desktop\images\myImage" + Str(i) + ".bmp")
WriteData(1, myImages()\bitmapdata, myImages()\dwSize)
CloseFile(1)
i + 1
Wend
And Here's my VideoStreamCallBack(), Where I think I'm missing something...
Code: Select all
Procedure VideoStreamCallBack( caphWnd.l, *lpVideo.VIDEOHDR )
AddElement(myImages())
PrepareBitMap( videoBMI\bmiHeader\biBitCount, videoBMI\bmiHeader\biWidth, videoBMI\bmiHeader\biHeight, @myImages(), @videoBMI)
For *i.Word = (*lpVideo\lpData + (*lpVideo\dwBufferLength)) To *lpVideo\lpData Step - 2
*reverse.Word = myImages()\bitmapdataOffset + j
; 16 W/ Alpha
;Red = *i\w >> 10
;Green = (*i\w & 992) >> 5
;Blue = *i\w & 31
; High -Intenst 16
;Red = *i\w >> 11
;Green = (*i\w & 1986) >> 5
;Blue = *i\w & 31
*reverse\w = *i\w
j + 2
Next
ProcedureReturn 1
EndProcedure


