Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

WebcamDS (DirectShow webcam)


  • Please log in to reply
46 replies to this topic

#1 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 09 April 2012 - 04:57 PM

I wrote a Udf to manage webcams with Direct Show instead of using avicap and dll32 dll.

Advantages vs the other Webcam UDF based on avicap32 and user32 dll:
- doesn't request to choose which webcam from list dropdown box
- you can precisely set: width, height, (bitplane ?? doesn't seem to work )
- you can set the video source resolution prior to scale it to the GUI and you can go up to 1920x1080 while with avicap you are limited at 640x480
- you can choose video compression in saving video and save the audio too (but uncompressed at the moment)
- you can use renderer you want, now VMR7 or VMR9
- you can make a zoom of some parts of the pic (also consecutive zoom of an area)
- you can go fullscreen EDIT: to exit from fullscreen press F1
- tested in W7 32-64bit and XP SP2
;------TODO: (don't know if and when)
; ---- TODO: take snapshot
; ---- TODO: windowless render preview, EVR ?
; ---- TODO: compress the audio?
; ---- TODO: more webcams in a single GUI
; ---- TODO: display rectangle on GUI during zoom selection
; ---- TODO: make more precise zoom selection in the bottomright border (due to border GUI, I think)
; ---- TODO: webcam controls luminosity, contrast, etc

- known problem: when returning from fullscreen, the gui doesn't display the webcam, but it's sufficient to press the reset to ripristinate

Besides, I upload some DirectShow interfaces that could be useful for other DS work.

Basically, to use this, you must call
_WebcamDS_Init()
at the beginning (it creates objects and fills some arrays you can use to populate your GUI, documented in the UDF).

Then you create your GUI, and you call
_WebcamDS_RenderWebcam(1,1,$hGUI,1,640,480,24)

this line means: webcamNumber 1, with audioPreview from Mic1, handleGUI ,rescale to the GUI, 640width, 480height, 24bpp


In my uploaded example, in the GUI there is from left: webcamList, audio micList, audio previewBox,CompressorList, audioCaptureBox,framerate, Save-Stop Buttons, resetPic, fullscreen(F1 to exit)

You can also see the video from one webcam and the audio from another one, ie:
_WebcamDS_RenderWebcam(1,2,$hGUI,1,640,480,24)

to change a webcam select it from the first combobox. If you want another audioMic, select the audio you want from the MicList, check the audioPrevBox and then select the webcam you want or press reset.

to zoom to a part of the pic, drag a rectangle with the mouse inside the pic, draw again if you want zoomIn. Press reset to return to normal pic.

to Save a video, you must select a video compressor from combobox and select the AudioCapture if you want (there must be also the same previewAudio), then press save (adjust the filename in the script). Stop when finished.

It's my first Direct Show attempt so I'm happy of the result ;)

EDIT:
it needs at least autoit beta 3.3.9.1
it's better to use in 32bit because there are more codecs
don't use DMO compressor (I have not implemented DMO), use the others:
for example DIVX or ffdshow (you set the parameters in their panel and then you can use them to record videos)
you need both UDF and interfaces files in the same dir (or adjust the paths).
I tried with 3 webcams: Microsoft LifeCam Studio (1920x1080), Logitech HD Pro C910 (1920x1080) and Philips 900NC (640x480)
Corrected example file to work well also with one webcam only.

version 1.0:

Attached Files


Edited by frank10, 21 April 2012 - 06:37 AM.








#2 CaptainClucks

CaptainClucks

    Unum Cavillator Spuria

  • Active Members
  • PipPipPipPipPipPip
  • 1,227 posts

Posted 09 April 2012 - 05:14 PM

lol, it rebooted my windows xp...
Spoiler

Warning: Posts by this user are subject to change or may disappear without notice.


#3 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 09 April 2012 - 05:18 PM

I only tried in W7 32-64bit ... Maybe it's something different with Direct Show?
I had no time to check for @error codes in my script to exit code nicely... sorry.

Edited by frank10, 09 April 2012 - 05:19 PM.


#4 knightz93

knightz93

    Seeker

  • Active Members
  • 23 posts

Posted 09 April 2012 - 05:33 PM

it only work when i change it to full screen.. but nice example.. and udf.. ;)
I will do my best in this forum my code : WindowsSwitcher3d()

#5 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 09 April 2012 - 05:41 PM

What happens before fullscreen?
Do you have the pic black?
With one webcam made this sometimes (I don't know why): try to press reset button until you get the pic.

#6 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 09 April 2012 - 11:02 PM

I tried XP and it works well also there.

I didn't see the reboot, but I discovered that with one webcam only there is a problem with an infinite loop.
I wrote the script with three webcam attached: one of them filled the array to build the combobox with two lines instead of one and so I wrote the code to adapt to this.
Now I corrected that line, now it should work as expected.

This is the new version:

Attached Files



#7 knightz93

knightz93

    Seeker

  • Active Members
  • 23 posts

Posted 10 April 2012 - 01:01 AM

What happens before fullscreen?
Do you have the pic black?
With one webcam made this sometimes (I don't know why): try to press reset button until you get the pic.


yeah, i get black screen.. thanks, when i press reset, it will work
I will do my best in this forum my code : WindowsSwitcher3d()

#8 CaptainClucks

CaptainClucks

    Unum Cavillator Spuria

  • Active Members
  • PipPipPipPipPipPip
  • 1,227 posts

Posted 10 April 2012 - 01:05 AM

Just tried it again.

When I run it, a huge gui shows up, about 2-3 seconds into the script, it causes a blue screen of death and the system restarts.
Spoiler

Warning: Posts by this user are subject to change or may disappear without notice.


#9 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 10 April 2012 - 07:30 AM

Do you have XP SP2?
Do you have latest DirectX installed? Have you installed DirectX 9.0? (it's not sufficient install directly the 11)
Which webcam do you use?

Which resolution do you use for desktop? I have tried with a desktop of 1920x1080 and 1440 resolution, so I made a GUI of 1280x720, but you can change the GUI res as you want: try making 640x480.

You could also change the second parameter regarding audioPreview to 0, just to test video only, and also the 4° parameter to not scale to GUI:
_WebcamDS_RenderWebcam(1,0,$hGUI,0,640,480,24)

Anyway I don't know what could cause a bluescreen ;)
I think is DirectShow or hardware related.

#10 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 10 April 2012 - 07:37 AM

yeah, i get black screen.. thanks, when i press reset, it will work


Do you start the script always with black pic?

Try changing the last parameter to 16 or 12:
_WebcamDS_RenderWebcam(1,1,$hGUI,1,640,480,16)
Some webcams do not use all bpp. Try also 320x240 res. It depends on the webcam hardware.

EDIT:
Try also without audioPreview.

Edited by frank10, 10 April 2012 - 08:09 AM.


#11 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 12 April 2012 - 09:53 AM

So, does nobody else tried it?
The compressed saving or zooming part?

#12 Qwerty212

Qwerty212

    Adventurer

  • Active Members
  • PipPip
  • 106 posts

Posted 15 April 2012 - 08:51 PM

It works fine with a Logitech C310 HD camera.

How can I use 2 cameras at the same time?

I'm going to use this udf a lot. Thanks for sharing it with us.

Edited by adolfito121, 15 April 2012 - 09:11 PM.


#13 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 16 April 2012 - 08:12 AM

I'm glad it works well. ;)

I had no time to try multiple webcams, but I'm interested in it.
I think it could be possible making two GUI, but the problem is that it's necessary to create multiple DS objects for the two GUIs.
At this moment the UDF doesn't take care of this.
I started creating an array of objects starting with the capture object but then I stopped.
Also because $ovideoWindow and $obasicVideo how do they refer to a capture object instead of another?

Or it could be multiple pic in the same GUI: it's surely possible, but it involves multiple graphs at the same time.
I know it's possible, but I didn't search it: if someone knows something or has some links of code examples, post it.
Maybe the other DS guys: trancexx or ProgAndy or Monoceres or...

#14 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 16 April 2012 - 12:31 PM

Alternatively, at the moment you can launch two instances of the script with different webcam settings.
This will create two GUI with two different webcams.

#15 joseLB

joseLB

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 251 posts

Posted 18 April 2012 - 02:16 PM

Hi Frank, I used it and it is wroking very well. Thanks for share this code.
I didnt test saving yet, but will do so soon.
I know that you didnt any camera control, like bright, contrast, etc.
A meanwile suggestion would be to do like skype, wen you select a camera , and click in configurations it opens the camera driver adjustment screen. As I have 2 cameras (Logitech HD c270 and Acer Cristal eye, depending on the webcam selected, it opens the specific adjustment screen

*ps: how I can determine the place at the gui where the webcam will be?
Thanks again
Jose

Edited by joseLB, 18 April 2012 - 02:29 PM.


#16 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 18 April 2012 - 03:03 PM

Yes, it could be useful having the panel settings opened, I don't know how to make it popup.
Instead I have the opposite problem only with my Logitech C910: when I select it, the panel pops up every time, but I do not want it! I don't know how to prevent it from popping up.

*ps: how I can determine the place at the gui where the webcam will be?

I don't understand this. Could you reformulate?

#17 joseLB

joseLB

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 251 posts

Posted 18 April 2012 - 05:11 PM

I don't understand this. Could you reformulate?

OK,

Probably it´s very simple and I couldnt seee.

On your example, I couldnt see where you specify the X,Y position where the webcam will be placed. On your example, there are some fields at top and the webcam screen comes just under them, left side. Where you specified it´s place?
Thnaks
Jose
* I had no problems selecting any of mine webcams... win 7 - 64bits, I5... they just appear, as expected.
** there are some parameters at _WebcamDS_RenderWebcam that you didn´t described (after bpp parameter)

Edited by joseLB, 18 April 2012 - 05:16 PM.


#18 DCCD

DCCD

    DCCD+

  • Active Members
  • PipPipPipPipPipPip
  • 340 posts

Posted 18 April 2012 - 06:02 PM

I get this fatal system error!

Attached Thumbnails

  • ABCD0011.jpg

Edited by DCCD, 18 April 2012 - 06:10 PM.


#19 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 18 April 2012 - 06:31 PM

On your example, I couldnt see where you specify the X,Y position where the webcam will be placed. On your example, there are some fields at top and the webcam screen comes just under them, left side. Where you specified it´s place?

I wrote the code to always place the webcam under the buttons line of the GUI, adding 26px:
EDIT: line 313-314 of UDF

It should be better to adapt them at different GUI...
If autoit could determine automatically where the GUI's free space begins. Is it possible to detect this?
If someone knows how to do this, I will change it.
Or it could be added as another two parameters, but I avoided that because there are a lot already...

** there are some parameters at _WebcamDS_RenderWebcam that you didn´t described (after bpp parameter)

In my version I have the description (I think it's the same I uploaded):
;                 $ibpp     - bitplane (if you put strange values it doesn't seem to change it..) normal: 12-16-24 ;                 $iZoomX  - rectangle Zoom offsetX (0 = noZoom) ;                               - if you use it manually, be careful to put values that are inside the original width-height of ;                                   webcam otherwise it doesn't work ;                               - it's better to use the Setrect func drawing the rectangle with mouse directly on the GUI ;                 $iZoomY       - rectangle Zoom offsetY (0 = noZoom) ;                 $iZoomW     - rectangle Zoom Width (0 = noZoom) ;                 $iZoomH       - rectangle Zoom Heigth (0 = noZoom)

Edited by frank10, 18 April 2012 - 07:01 PM.


#20 frank10

frank10

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 18 April 2012 - 06:33 PM

I get this fatal system error!

Which OS and autoit version do you use?
Do you have latest DirectX installed? Have you installed DirectX 9.0? (it's not sufficient install directly the 11)

EDIT:
Do you have latest video drivers installed? which graphic card?

Edited by frank10, 18 April 2012 - 07:14 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users