Taking a picture with my webcam Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Tyrone Malick

Taking a picture with my webcam  Topic is solved

24 Oct 2017, 13:22

Just got done searching the documentation but found nothing about webcam / camera controls.

On my GUI I have a button that says take a photo. IS there anyway to do this and if so what is the method?

I tried https://autohotkey.com/board/topic/1627 ... om-webcam/
https://autohotkey.com/board/topic/9637 ... thout-gui/
https://autohotkey.com/board/topic/62379-logon-camera/ (the code itself doesn't work for anything on windows 10)
Tradesxi

Re: Taking a picture with my webcam

16 Aug 2018, 16:17

Masonjar13 wrote:https://autohotkey.com/board/topic/15662-add-vfw-video-for-windows-to-ahk-gui-works-somewhat/?p=108361


That works very poorly

no script that takes a photo without asking for source after the second run and saves the photo? I do not mind if gui must show but something that works
User avatar
Masonjar13
Posts: 1389
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Taking a picture with my webcam

16 Aug 2018, 17:55

Easy enough to just remove the gui elements and have it automate everything instead. But note that the stream needs to be opened first, so the cam control still needs to be in a gui, but you can just hide it.
Tradesxi

Re: Taking a picture with my webcam

16 Aug 2018, 18:48

Masonjar13 wrote:Easy enough to just remove the gui elements and have it automate everything instead. But note that the stream needs to be opened first, so the cam control still needs to be in a gui, but you can just hide it.


I have this code doing it, but sometimes it pops up the box asking for the camera source, usually the first time it works great, the second time it asks for camera source even if i quit the program and run it again, can you please test it?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
Masonjar13
Posts: 1389
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Taking a picture with my webcam

17 Aug 2018, 02:45

Tradesxi wrote:the box asking for the camera source

What "box" are you referring to?

Anyways, works fine as-is. Cleaned it up a bit, though.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Tradesxi

Re: Taking a picture with my webcam

17 Aug 2018, 04:26

thank you for the cleanup, let me tell you that for years now people tried to find solution and still as hard as i tried and posted so much begging, nobody can find solution that is reasonable

i will give one example https://autohotkey.com/board/topic/2666 ... ce-dialog/

your code that you posted will work on many machines even if you run it many times again and again, but on many machines, after you run it once or twice it will ask for a source like the post i just shared shows.

The first time it runs it works very well, second time it sometimes asks for video source and many case if you click ok it will take blank photo.

It is as if the first time it runs it grabs onto some dll resource and does not let go of it even after program exists, but if u wait a while like 20 minutes it will work again without asking for source

even after all this time of trying to get help, i stay hoping someone will figure it out
tmplinshi
Posts: 1242
Joined: 01 Oct 2013, 14:57

Re: Taking a picture with my webcam

17 Aug 2018, 10:13

Here is a working example using TesoSeeu.ocx:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Or a simple example without showing GUI window:

Code: [Select all] [Download] GeSHi © Codebox Plus

RegCOM("TesoSeeu.ocx.manifest")

Gui, Add, ActiveX, w0 h0 vCamaOcx, {7EEAA4B5-DE19-493F-950C-4053B77195D2}
CamaOcx.openCapDev(DevIdx:=1, 0)
Sleep, 100

g_nImgFmt := 1
hBuffer := CamaOcx.SnapOne(g_nImgFmt)
nIsz := CamaOcx.GetImgLen(g_nImgFmt)
FileOpen("OneSnap.bmp", "w").RawWrite(hBuffer+0, nIsz)
ExitApp
Attachments
TesoSeeu.ocx example.zip
(33.41 KiB) Downloaded 4 times
Tradesxi

Re: Taking a picture with my webcam

17 Aug 2018, 10:51

tmplinshi wrote:Here is a working example using TesoSeeu.ocx


Thank you for that one, that is too many things to ask someone to do just to take a picture

I still am hopeful someone will fix the current solution i posted
User avatar
Frosti
Posts: 112
Joined: 27 Oct 2017, 14:30
Facebook: They have no decency!
Google: They have no decency!
GitHub: Ixiko
Location: Somwhere between Mars and Earth
Contact:

Re: Taking a picture with my webcam

21 Aug 2018, 13:20

I had an equal issue like you. The first thing I changed was my DLLCall. If you use Unicode version of Autohotkey use unicode DllCall of this function:

Code: [Select all] [Download] (Unbenannt.ahk)GeSHi © Codebox Plus

Cap_GetDriverDescription(wDriver)
{
VarSetCapacity(lpszName, 100)
VarSetCapacity(lpszVer, 100)
res := DLLCall("avicap32.dll\capGetDriverDescriptionW" <- A is ANSI, W is Unicode
.
.
.
.


The second cause came from the webcam driver. I must check the existence of an ongoing service process and start this process previously if it does not exist.
Tradesxi

Re: Taking a picture with my webcam

21 Aug 2018, 16:08

Frosti wrote:The second cause came from the webcam driver. I must check the existence of an ongoing service process and start this process previously if it does not exist.
so happy you replied, can you tell me what you mean and how to check for that service?
User avatar
Frosti
Posts: 112
Joined: 27 Oct 2017, 14:30
Facebook: They have no decency!
Google: They have no decency!
GitHub: Ixiko
Location: Somwhere between Mars and Earth
Contact:

Re: Taking a picture with my webcam

22 Aug 2018, 06:34

It's a hauppage usb stick to capture the output of a sonography device. If this service isn't started properly I have only a black screen or in worst case my little script is hanging. In the last case I have to restart the computer. Hauppauge uses their own capture gui. So I start this hauppauge program and wait for video stream. Then I close this program and start my script. That's all.

Return to “Ask For Help”

Who is online

Users browsing this forum: anobayan, shgilad81 and 69 guests