Help with webcam or video stream

Just starting out? Need help? Post your questions and find answers here.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

@Wolf - You're missing the SetWindowCallback. Add it just before you take the Snapshot()

Code: Select all

SetWindowCallback(@myWindowCallback())  
snapshot()
:)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Wolf
Enthusiast
Enthusiast
Posts: 232
Joined: Sat Apr 03, 2004 12:00 pm
Location: S.T

Post by Wolf »

Oh yes :D

I now add it and work perfect.

Sparkie i always thank you for your nice helps :wink:


Best regards.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Always glad to help Wolf :)

I'll let you know if and when I find a better method of handling the Video Source window. :wink:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
real
User
User
Posts: 49
Joined: Fri Oct 08, 2004 5:17 am

Re: Help with webcam or video stream

Post by real »

Sorry for re-opening this topic... :oops:

Could anybody give me an example, how to change the resolution to 640 x 480 pixels without any dialogs... please? I'd like to make a snapshot in 640 x 480 and this is supported by the webcam, but standard webcam is a resolution of 352 x 288 pixels.

Thanks,
René
Windows 7 x64, PureBasic 4.31 & 4.40b4 x86
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Re: Help with webcam or video stream

Post by Sparkie »

I believe WM_CAP_SET_VIDEOFORMAT will do what you want. I won't have time to try it out until this weekend.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
real
User
User
Posts: 49
Joined: Fri Oct 08, 2004 5:17 am

Re: Help with webcam or video stream

Post by real »

Okay, I know that i have to pass it via SendMessage_() to the capture window, but I'm note sure about the parameters to use.
Windows 7 x64, PureBasic 4.31 & 4.40b4 x86
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Re: Help with webcam or video stream

Post by Sparkie »

See if this helps you until I have time to finish the code.

Code: Select all

  bmi.BITMAPINFO
  bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
  ;Use zero parameters to get current struct size
  structSize = SendMessage_(hWndC, #WM_CAP_GET_VIDEOFORMAT, 0, 0)
  ;Now use corrected parameters to get info
  SendMessage_(hWndC, #WM_CAP_GET_VIDEOFORMAT, structSize, @bmi)
  ;Change to a valid size only or crash will occur
  bmi\bmiHeader\biWidth = 640
  bmi\bmiHeader\biHeight = 480
  bmi\bmiHeader\biSizeImage = bmi\bmiHeader\biHeight * bmi\bmiHeader\biWidth * 3
  bmi\bmiHeader\biBitCount = 24
  ;Set new size
  SendMessage_(hWndC, #WM_CAP_SET_VIDEOFORMAT, structSize, bmi)
  capW = bmi\bmiHeader\biWidth
  capH = bmi\bmiHeader\biHeight
  SetWindowPos_(hWndC, 0, 0, 0, capW, capH, #SWP_NOMOVE | #SWP_NOZORDER | #SWP_FRAMECHANGED)
  UpdateWindow_(hWndC)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
max_aigneraigner@web.de
User
User
Posts: 67
Joined: Sun Nov 02, 2008 10:37 pm
Location: Bavaria
Contact:

Re: Help with webcam or video stream

Post by max_aigneraigner@web.de »

doesn't function on windows 7
neither with PB nor c++..

alternative?
3D Projects
A ship is safest in the harbor, but that is not what ships are built for.
Post Reply