|
Post by Rod on Sept 14, 2022 6:23:10 GMT -5
This is code, supplied by Code!, in another thread about ugly pdf creation. This is an extract of the camera code. It allows you to start your PC's webcam and then take snapshots. You can do this programatically or by clicking the button. There are examples elsewhere about how to open a .bmp file and analyse its contents. You will be able to look for differences in certain areas. You might also look for shapes or you can just do a time slice record of activity. Anyway you now have control of your WebCam which you may not have played with yet.
Although there is no code to close the camera it seems to behave on my system and closes gracefully when I close the window.
'WebCam management, code supplied by Code! nomainwin WindowWidth=700 WindowHeight=600 button #scr, "Snapshot... ", [snap], UL, 450, 500 button #scr, "Start cam... ", [cam], UL, 100, 500 graphicbox #scr.gr, 10, 10, 640, 480 open "WebCam" for graphics_nf_nsb as #scr wait
[snap] ZWTEST=HEXDEC("&H400") tg1=ZWTEST+61 tg2=ZWTEST+25 calldll #user32, "SendMessageA", cap as long,tg1 as long,0 as long,0 as long,r as long calldll #user32, "SendMessageA", cap as long,tg2 as long,0 as long,"image.bmp" as PTR,r as long loadbmp "image", "image.bmp" #scr.gr "down ; drawbmp image 0 0" wait
[cam] hw = hwnd(#scr) reeks = _WS_VISIBLE OR _WS_CHILD open "avicap32.dll" for DLL as #nd calldll #nd , "capCreateCaptureWindowA", 0 as long, reeks as ptr,10 as long, 10 as long,640 as long, 480 as long,hw as long,0 as long,cap as long calldll #user32, "SendMessageA", cap as long,1034 as long,0 as long,0 as long,r as long
'if webcam window is black un rem these lines once and choose YUY in the dialog window,click apply 'calldll #user32, "SendMessageA", cap as long,1077 as long,1 as long,0 as long,r as long 'calldll #user32, "SendMessageA", cap as long,1076 as long,20 as long,0 as long,r as long 'calldll #user32, "SendMessageA", cap as long,1074 as long,1 as long,0 as long,r as long 'calldll #user32, "SendMessageA", cap as long,1065 as long,0 as long,0 as long,r as long wait
|
|
code
New Member
Posts: 30
|
Post by code on Sept 14, 2022 9:29:20 GMT -5
To disconnetct the camera it is:(1024+61)=(1085) calldll #user32, "SendMessageA", cap as long,1085 as long,0 as long,0 as long,r as long Something like that... Regards, code edit:[ I was looking for a code page on the internet wich explains '1024'(WM_USER=1024)' Link : linkBut for now I cant find sort a page...(more options....) So : 1024+11(WM_USER+11)=Disconnect ]
|
|
code
New Member
Posts: 30
|
Post by code on Sept 14, 2022 10:38:28 GMT -5
Sorry , I was wrong again its 1035 not 1085
calldll #user32, "SendMessageA", cap as long,1035 as long,0 as long,0 as long,r as long
|
|
code
New Member
Posts: 30
|
Post by code on Dec 10, 2022 21:50:43 GMT -5
Here a example of the website/options... link
|
|
code
New Member
Posts: 30
|
Post by code on Dec 13, 2022 19:00:41 GMT -5
Hi, here a 'ugly' example to record a video...
nomainwin WindowWidth=800 WindowHeight=600
button #scr, "Start recording... ", [startv], UL, 440, 500 button #scr, "Stop recording... ", [stop], UL, 600, 500
res=mkdir("C:\video\")
cap=0 open "Video..." for graphics_nsb as #scr
wait
[stop] ZWTEST=HEXDEC("&H400")
tg8=ZWTEST+68 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long tg8=ZWTEST+69 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long
tg8=ZWTEST+71 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long
tg8=ZWTEST+68 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long tg8=ZWTEST+69 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long open "winmm.dll" for dll as #mci calldll #mci,"mciSendStringA","Open c:\video\test.avi type avivideo alias movie" as ptr,0 as long,0 as long, 0 as long, r as long calldll #mci,"mciSendStringA","play movie" as ptr,0 as long,0 as long, 0 as long, r as long
wait
[startv] calldll #kernel32, "Beep", 200 as long,400 as long,r as long calldll #kernel32, "Beep", 200 as long,400 as long,r as long calldll #kernel32, "Beep", 200 as long,400 as long,r as long
hw = hwnd(#scr)
reeks = _WS_VISIBLE OR _WS_CHILD
open "avicap32.dll" for DLL as #nd
calldll #nd , "capCreateCaptureWindowA", 0 as long, reeks as ptr,10 as long, 10 as long,350 as long, 280 as long,hw as long,0 as long,cap as long
calldll #user32, "SendMessageA", cap as long,1034 as long,0 as long,0 as long,r as long
ZWTEST=HEXDEC("&H400")
tg8=ZWTEST+53 calldll #user32, "SendMessageA", cap as long,tg8 as long,1 as long,0 as long,r as long
tg8=ZWTEST+52 calldll #user32, "SendMessageA", cap as long,tg8 as long,2 as long,0 as long,r as long
tg8=ZWTEST+50 calldll #user32, "SendMessageA", cap as long,tg8 as long,1 as long,0 as long,r as long
tg8=ZWTEST+42 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long
tg8=ZWTEST+20 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,"C:\video\test.avi" as ptr,r as long
tg8=ZWTEST+62 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long
wait
Regards,
code
|
|
code
New Member
Posts: 30
|
Post by code on Feb 24, 2023 20:44:38 GMT -5
To avoid the freeze i came up with this :
nomainwin WindowWidth=800 WindowHeight=600
button #scr, "Start recording... ", [startv], UL, 440, 500 button #scr, "Stop recording... ", [stop], UL, 600, 500
res=mkdir("C:\video\")
cap=0 open "Video..." for graphics_nsb as #scr
wait
[stop] ZWTEST=HEXDEC("&H400")
tg8=ZWTEST+68 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long tg8=ZWTEST+69 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long
tg8=ZWTEST+71 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long
tg8=ZWTEST+68 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long tg8=ZWTEST+69 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long open "winmm.dll" for dll as #mci calldll #mci,"mciSendStringA","Open c:\video\test.avi type avivideo alias movie" as ptr,0 as long,0 as long, 0 as long, r as long calldll #mci,"mciSendStringA","play movie" as ptr,0 as long,0 as long, 0 as long, r as long
wait
[startv] calldll #kernel32, "Beep", 200 as long,400 as long,r as long calldll #kernel32, "Beep", 200 as long,400 as long,r as long calldll #kernel32, "Beep", 200 as long,400 as long,r as long
hw = hwnd(#scr)
reeks = _WS_VISIBLE OR _WS_CHILD
open "avicap32.dll" for DLL as #nd
calldll #nd , "capCreateCaptureWindowA", 0 as long, reeks as ptr,10 as long, 10 as long,350 as long, 280 as long,hw as long,0 as long,cap as long
calldll #user32, "SendMessageA", cap as long,1034 as long,0 as long,0 as long,r as long
struct ds, _ x1 as long, _ x2 as long, _ x3 as long, _ x4 as long, _ x5 as long, _ x6 as long, _ x7 as long, _ x8 as long, _ x9 as long, _ x10 as long, _ x11 as long, _ x12 as long, _ x13 as long, _ x14 as long, _ x15 as long, _ x16 as long, _ x17 as long, _ x18 as long
ds.x1.struct =66667 ds.x2.struct = 0 ds.x3.struct = 10 ds.x4.struct = 1 ds.x5.struct = 3240000 ds.x6.struct =0 ds.x7.struct =10 ds.x8.struct =10 ds.x9.struct =0 ''audio... ds.x10.struct =10 ds.x11.struct =0 ds.x12.struct =0 ds.x13.struct =0 ds.x14.struct =0 ds.x15.struct =0 ds.x16.struct =0 ds.x17.struct =5 ds.x18.struct =10
ZWTEST=HEXDEC("&H400")
tg8=ZWTEST+53 calldll #user32, "SendMessageA", cap as long,tg8 as long,1 as long,0 as long,r as long
tg8=ZWTEST+64 calldll #user32, "SendMessageA", cap as long,tg8 as long,96 as long,ds as struct,r as long
tg8=ZWTEST+52 calldll #user32, "SendMessageA", cap as long,tg8 as long,2 as long,0 as long,r as long
tg8=ZWTEST+50 calldll #user32, "SendMessageA", cap as long,tg8 as long,1 as long,0 as long,r as long
tg8=ZWTEST+42 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long
tg8=ZWTEST+20 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,"C:\video\test.avi" as ptr,r as long
tg8=ZWTEST+62 calldll #user32, "SendMessageA", cap as long,tg8 as long,0 as long,0 as long,r as long
wait
Regards,
code
|
|
|
Post by honkytonk on Feb 25, 2023 10:59:42 GMT -5
What to modify for a USB camera? If it's possible of course.
|
|
code
New Member
Posts: 30
|
Post by code on Feb 25, 2023 11:46:35 GMT -5
Hi,
Thx for your reply... I just plugged in a webcam and windows automatically recognized it ... So when popup now , you can choose about 2 camera's and then record But here its unstable...its hard to get a .avi without problems...
Regards,
code
|
|
|
Post by honkytonk on Feb 25, 2023 12:36:08 GMT -5
Hard but interesting
|
|