Page 3 of 3
Posted: Wed Oct 12, 2005 12:44 pm
by Nik
Thats cool and it works i just wanted to tell you that there are sometimes black bars on the image but I don“t know where they are coming from
With
the bars are gone. But there are some other Image failures.
Another sucpicious thing is that
Code: Select all
Procedure capFrameCallback(hWnd.l, *lpVHdr.VIDEOHDR)
If hWnd
hBmp = UseImage( 1 )
w = ImageWidth()
h = ImageHeight()
bmi.BITMAPINFO
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = w
bmi\bmiHeader\biHeight = h
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 24
bmi\bmiHeader\biCompression = #BI_RGB
hdc = StartDrawing(ImageOutput())
If hdc
SetDIBits_( hdc, hBmp, 0, h, *lpVHdr\lpData, bmi, #DIB_RGB_COLORS)
StopDrawing()
EndIf
; If StartDrawing(WindowOutput())
; DrawImage(UseImage(1), 0, 0)
; StopDrawing()
; EndIf
EndIf
EndProcedure
works with less image failures
Posted: Wed Oct 12, 2005 12:51 pm
by Kukulkan
Hi Nik,
You have to take care about the following values:
- bitmap-depth of your Windows-screen (16, 24 or 32 Bit)
- bitmap-depth of your webcam (maybe some driver-properties)
You need 24 Bit at a minimum. In this case you have 3 bytes per pixel. If you are using 32 Bit, you have to calculate with 4 Byte per pixel. Using 16 Bit screen results in some really nice complications...
Kukulkan[/quote]
Posted: Wed Oct 12, 2005 12:55 pm
by Nik
Look at this:
It shows that ther must be an Error in the code.
Code: Select all
; important: configure your web cam : 320*240*rgb24
#WM_CAP_START = #WM_USER
#WM_CAP_SET_CALLBACK_FRAME = #WM_CAP_START + 5
#WM_CAP_DRIVER_CONNECT = #WM_CAP_START + 10
#WM_CAP_SET_OVERLAY = #WM_CAP_START + 51
#WM_CAP_SET_PREVIEW = #WM_CAP_START + 50
#WM_CAP_SET_PREVIEWRATE = #WM_CAP_START + 52
#WM_CAP_SET_SCALE = #WM_CAP_START + 53
Structure VIDEOHDR
lpData.l
dwBufferLength.l
dwBytesUsed.l
dwTimeCaptured.l
dwUser.l
dwFlags.l
dwReserved.l[4]
EndStructure
Procedure capFrameCallback(hWnd.l, *lpVHdr.VIDEOHDR)
If hWnd
hBmp = UseImage( 1 )
w = ImageWidth()
h = ImageHeight()
bmi.BITMAPINFO
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = w
bmi\bmiHeader\biHeight = h
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
bmi\bmiHeader\biCompression = #BI_RGB
hdc = StartDrawing(ImageOutput())
If hdc
SetDIBits_( hdc, hBmp, 0, h, *lpVHdr\lpData, bmi, #DIB_RGB_COLORS)
StopDrawing()
EndIf
If StartDrawing(WindowOutput())
DrawImage(UseImage(1),0 , 250)
StopDrawing()
EndIf
EndIf
EndProcedure
OpenWindow(0,0,0,325,495,#PB_Window_SystemMenu|#PB_Window_WindowCentered,"cam")
If OpenLibrary(0,"avicap32.dll")
hWndC = CallFunctionFast(IsFunction(0,"capCreateCaptureWindowA"),"cap",#WS_CHILD|#WS_VISIBLE,0,0,320,240,WindowID(),1)
;hWndC = CallFunctionFast(IsFunction(0,"capCreateCaptureWindowA"),"cap",#WS_CHILD,0,0,320,240,WindowID(),1)
EndIf
CreateImage(1, 320, 240)
SendMessage_(hWndC, #WM_CAP_DRIVER_CONNECT, 0, 0)
SendMessage_(hWndC, #WM_CAP_SET_SCALE, #True, 0)
SendMessage_(hWndC, #WM_CAP_SET_OVERLAY, #True, 0)
SendMessage_(hWndC, #WM_CAP_SET_PREVIEW, #True, 0)
SendMessage_(hWndC, #WM_CAP_SET_PREVIEWRATE, 60, 0)
SendMessage_(hWndC, #WM_CAP_SET_CALLBACK_FRAME, 0, @capFrameCallback())
ActivateWindow()
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
SendMessage_(hWndC, #WM_CAP_SET_CALLBACK_FRAME, 0, 0)
Break
EndSelect
ForEver
End
Posted: Fri Oct 14, 2005 2:12 pm
by Nik
Any news on this?
Posted: Fri Oct 21, 2005 9:04 pm
by Nik
Hey Guys, is there an answer yet because the code with SetDIBits would be perfect, nobody knows what the error is because the plot version works.
Any help would be greatly appriciated
bye Nik
Posted: Fri Oct 21, 2005 10:18 pm
by FloHimself
nik, what is your problem exactly?
Posted: Sat Oct 22, 2005 9:42 am
by Kukulkan
Hi nik,
...nobody knows what the error is...
This is exactly the point. What is your problem? You never told us...
Kukulkan
Posted: Sat Oct 22, 2005 12:34 pm
by Flype
yes, both plot method and mbi method works with my webcam.
bmi's one is far faster.
Posted: Sat Oct 22, 2005 2:31 pm
by Nik
Well thats crazy that it works for you while here only the plot method is working. But with the other method one thinks it works but when you draw the images seperated like in the plot method the one drawn with bmi stays black.
bye Nik
Posted: Sat Oct 22, 2005 4:16 pm
by FloHimself
you should really make sure that your cam is working in
RGB mode. dont use I420 or YUV or something like that!
also make sure you use the right bit depth in code and
your cam options.