News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

WebCam Video

Started by PriNet, November 28, 2015, 08:50:52 PM

Previous topic - Next topic

jj2007

Quote from: Siekmanski on November 30, 2015, 09:59:24 PM
We give the device number so avicap knows which device to connect:
   invoke   SendMessage,hCaptureWnd,WM_CAP_DRIVER_CONNECT,camera_devicenumber,0
This is where the source dialog pops up.

He takes snapshots, we want full-rate movies.

Even at the Windows Development Center they can't give us a solution...

https://social.msdn.microsoft.com/Forums/windows/en-US/858192dd-fbc9-4ea1-91fc-9f2d8286b4f7/webcam-access-in-c-using-system-calls-only-works-once-per-restart?forum=winformsdatacontrols

Here is my solution:
push 9
.Repeat
invoke SendMessage, hCapWin, WM_CAP_DRIVER_CONNECT, 0, 0
deb 4, "Connect", eax
dec stack
.Until Sign? || eax
pop ecx
mov isConnected, eax


I've lost a lot of time in the reboot loop until I found somewhere the advice "try again until it connects". And it works.

Getting rid of the popup box:
  mov hFGW, rv(GetForegroundWindow)
  .if Instr_(Win$(eax), "video", 1)
      invoke ShowWindow, hFGW, SW_HIDE
      invoke SendMessage, hFGW, WM_CLOSE, 0, 0
      Delay 127
  .endif


There may be languages that don't have "video" in the name of that box, though.

Siekmanski

+/- Ten years ago we didn't had this problem with VFW.  :(

Jochen, is the DirectShow example working correct on your machine?
Creative coders use backward thinking techniques as a strategy.

Siekmanski

Implemented Jochens solution without the "source dialog pop up" solution :


Hope this works on your computers......  :biggrin:
Creative coders use backward thinking techniques as a strategy.

TWell

#33
Windows 7  :t

Siekmanski

Thanks Tim.

Because I don't have the "source dialog pop up bug", and I don't know where it pops up.
The solution to prevent this may have to be implemented somewhere else in the source code.

I have placed it in the "GetCamera proc"


GetCamera proc camera_dev:DWORD
LOCAL counter:dword
LOCAL FGhwnd:dword
       
    mov     counter,100
connectLP:
    invoke  SendMessage,hCaptureWnd,WM_CAP_DRIVER_CONNECT,camera_dev,0
    cmp     eax,TRUE
    je      connect_Ok
    dec     counter
    jnz     connectLP

    invoke  MessageBox,hWnd,TEXT_("Can not connect the camera !"),TEXT_("Error"),MB_OK OR MB_ICONERROR
    mov     eax,FALSE
    ret
connect_Ok:

    invoke  SendMessage,hCaptureWnd,WM_CAP_DRIVER_GET_CAPS,sizeof CaptureCaps,addr CaptureCaps

    invoke  SendMessage,hCaptureWnd,WM_CAP_SET_SCALE,TRUE,0
    invoke  SendMessage,hCaptureWnd,WM_CAP_SET_PREVIEWRATE,1000/30,0
    invoke  SendMessage,hCaptureWnd,WM_CAP_SET_PREVIEW,TRUE,0
    invoke  SendMessage,hCaptureWnd,WM_CAP_SET_OVERLAY,TRUE,0

    invoke  GetForegroundWindow
    mov     FGhwnd,eax
   
    invoke  GetWindowText,eax,addr szString_buffer,128
   
;   invoke  lstrcmp,addr szString_buffer,TEXT_("Videobron")
    invoke  lstrcmp,addr szString_buffer,TEXT_("video")
    test    eax,eax
    jnz     compare_done
   
;    invoke  MessageBox,hWnd,addr szString_buffer,TEXT_("Window check"),MB_OK
       
    invoke ShowWindow,FGhwnd,SW_HIDE
    invoke  SendMessage,FGhwnd,WM_CLOSE,0,0

compare_done:
    mov     eax,TRUE
    ret

GetCamera endp


Is this the dialog that pops up ?


Creative coders use backward thinking techniques as a strategy.

jj2007

Quote from: Siekmanski on November 30, 2015, 11:44:30 PMIs this the dialog that pops up ?

Yes, that's the one. Sorry, no time yet to test the DirectShow example...

PriNet

Darn, (go figure) I have to work some pretty long hours these next couple days. I'm anxious to get back and see what has transpired here, looks like I need to try some new examples y'all are providing. I'm the words of Arnold, "I'll be back"...

Thankx for everyone's input here.

Oh... btw; I'm on win7-64 if that gives any insight on the popup window issue...
-G
There has GOT to be a harder way...

jj2007

Direct Show on Win7-64:

IMediaControl.Run niet OK  ::)

Then "Misc routines error", and that's it... and afterwards the camera is blocked, both with my own app (attached) and the official Acer Crystal Eye that always worked fine until now :(

So I will reboot now ;-)

P.S.: Could somebody with more than one camera installed please test if the combobox works in my attached example? Thanks.

Farabi

I had no idea why MS make this problem to appear. I kinda worried about what harm can be done if I answered this. I had no idea, but my OS multiple time having problem. We better not answer kindly about this.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

Siekmanski

Hi Jochen,

I have only 1 camera connected ( your example works OK )

Anybody else have tested the DirectShow example ?

Marinus
Creative coders use backward thinking techniques as a strategy.

HSE

#40
Hi Marinus!

Work very well here with an old and cheap camera.

HSE

PD Windows 7 Ultimate Services Pack1
Equations in Assembly: SmplMath

TWell

DirectShow example don't show window.
Have to kill with task-manager:(
OS Windows 7 Home premium.

Siekmanski

Thanks guys for testing.

@Tim and @Jochen,

I have added a NullRenderer filter to the render chain.
Hope this solves the problem of the DirectShow example from not showing the render screen.

Marinus
Creative coders use backward thinking techniques as a strategy.

TWell


jj2007

#44