Video for Windows: VfW

Share your advanced PureBasic knowledge/code with the community.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 543
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: VfW (Video for Windows)

Post by bbanelli »

Hi JHPJHP,

although all your OpenCV camera examples work with my camera on W7 x64, this one only shows black screen... :(

What info could I provide so you could see what's wrong?
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: VfW (Video for Windows)

Post by JHPJHP »

Hi bbanelli,

Thank you for the feedback and the offer to provide information to fix the current problem.

I've improved the handoff between OpenCV to VfW, please let me know if the update fixes the issue you reported.

NB*: I've also added the OpenCV license file to the package: references\license.txt.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 543
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: VfW (Video for Windows)

Post by bbanelli »

JHPJHP wrote:Hi bbanelli,

Thank you for the feedback and the offer to provide information to fix the current problem.

I've improved the handoff between OpenCV to VfW, please let me know if the update fixes the issue you reported.

NB*: I've also added the OpenCV license file to the package: references\license.txt.
Didn't help. When I try to capture image/video (on black screen), this is the Debuger output.

Code: Select all

ERROR: Out of memory
ERROR: 

Capture Start
Setting up for capture - Please wait

Hit ESCAPE or click to end capture
Captured 0 frames (0 dropped) 0.000 sec.
Captured 0 frames (0 dropped) 0.300 sec.
Captured 1 frames (0 dropped) 0.448 sec.
Captured 2 frames (0 dropped) 0.543 sec.
Captured 3 frames (0 dropped) 0.656 sec.
Captured 5 frames (1 dropped) 0.754 sec.
Captured 6 frames (1 dropped) 0.849 sec.
Captured 7 frames (1 dropped) 0.944 sec.
Captured 9 frames (2 dropped) 1.056 sec.
Captured 11 frames (3 dropped) 1.154 sec.
Captured 12 frames (3 dropped) 1.249 sec.
Captured 13 frames (3 dropped) 1.344 sec.
Captured 15 frames (4 dropped) 1.456 sec.
Captured 15 frames (4 dropped) 1.486 sec.
Captured 17 frames (5 dropped) 1.554 sec.
Captured 18 frames (5 dropped) 1.649 sec.
Captured 19 frames (5 dropped) 1.744 sec.
Captured 21 frames (6 dropped) 1.856 sec.
Captured 23 frames (7 dropped) 1.953 sec.
Captured 24 frames (7 dropped) 2.049 sec.
Captured 25 frames (7 dropped) 2.144 sec.
Captured 27 frames (8 dropped) 2.256 sec.
Captured 29 frames (9 dropped) 2.353 sec.
Captured 30 frames (9 dropped) 2.448 sec.
Captured 31 frames (9 dropped) 2.543 sec.
Captured 33 frames (10 dropped) 2.656 sec.
Captured 35 frames (11 dropped) 2.753 sec.
Captured 36 frames (11 dropped) 2.848 sec.
Captured 38 frames (12 dropped) 2.961 sec.
Captured 38 frames (12 dropped) 2.976 sec.
Captured 39 frames (12 dropped) 3.056 sec.
Captured 41 frames (13 dropped) 3.153 sec.
Captured 42 frames (13 dropped) 3.248 sec.
Captured 44 frames (14 dropped) 3.361 sec.
Captured 45 frames (14 dropped) 3.456 sec.
Captured 47 frames (15 dropped) 3.553 sec.
Captured 48 frames (15 dropped) 3.648 sec.
Captured 50 frames (16 dropped) 3.761 sec.
Captured 51 frames (16 dropped) 3.856 sec.
Captured 53 frames (17 dropped) 3.953 sec.
Captured 54 frames (17 dropped) 4.048 sec.
Captured 56 frames (18 dropped) 4.161 sec.
Captured 57 frames (18 dropped) 4.256 sec.
Captured 59 frames (19 dropped) 4.353 sec.

Captured 60 frames (19 dropped) 4.448 sec.
Finished capture, now writing frame 60
Finished capture, now writing frame 60
Captured 4.449 sec.  60 frames (19 dropped) (13.486 fps).  49061 audio bytes (11,025 sps)
ERROR: Dropped 19 of 60 frames (31.6%) during capture.
Capture End

ERROR: 

ERROR: Out of memory
ERROR: 
No pictures are captured, but there is a video though.

How come you didn't use cvQueryFrame and cvShowImage functions to display live video?
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: VfW (Video for Windows)

Post by JHPJHP »

Hi bbanelli,

Thanks again for the feedback.
How come you didn't use cvQueryFrame and cvShowImage functions to display live video?
This is a "Video for Windows" implementation not OpenCV, but because VfW breaks down starting the webcam, I'm using OpenCV to initiate the link. It was a hack I thought would work acrossboard, but obviously I was wrong even though I tested it on 3 separate machines of varying webcam drivers and operating systems.

Can you try setting the first dialog (video source) to True.
- mainfiles\vfw_capture.pb: dlg1.b = #True

It's possible that it's defaulting to the wrong video source.
Last edited by JHPJHP on Wed Dec 17, 2014 6:10 pm, edited 2 times in total.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 543
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: VfW (Video for Windows)

Post by bbanelli »

JHPJHP wrote:Hi bbanelli,

Thanks again for the feedback.
How come you didn't use cvQueryFrame and cvShowImage functions to display live video?
This is a "Video for Windows" implementation not OpenCV, but because VfW breaks down initiating the webcam, I'm using OpenCV to initiate the link. It was a hack I thought would work acrossboard, but obviously I was wrong even though I tested it on 3 separate machines of varying webcam drivers and operating systems.

Can you try setting the first dialog (video source) to True.
- mainfiles\vfw_capture.pb
-- dlg1.b = #True

It's possible that it's defaulting to the wrong video source.
I only have one source, HD web camera. As said, works like a charm with OpenCV.

Changing dlg1.b = #True only gave me an option to choose device, but since there is only one, I couldn't have done much. Strangely, video recording works, with some frames dropped, though.

In any case, interesting code, as always! :)

With my best,

Bruno
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: VfW (Video for Windows)

Post by JHPJHP »

Hi bbanelli,

Much appreciated. I'll probably play-around a little more with it, but I think VfW may be getting to old for Microsoft to support.

I've just switched to Windows 8.1 full-time and I'm noticing some strange behaviour with some of my other scripts. I think I'll spend the next few days seeing what I can do with them.

Cheers!
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: VfW (Video for Windows)

Post by Mythros »

Hi JHP! :) EXCELLENT plugin! Can you please add a video streaming server / client example to the pack? I am curious to see if this can be done.

Thanks again!

Sincerely,

~Mythros
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: VfW (Video for Windows)

Post by JHPJHP »

Hi Mythros,

Thank you for the acknowledgement.

I won't be adding anything more to VfW (Video for Windows) then the following update. I only created this thread because I thought it might assist someone still using the technology.

-----------------------------------------------------------------------

Added a couple new Procedures: SetResolution / ResolutionList.
- builds a resolution list supported by your webcam, adding it as a context submenu
- the last / highest resolution is defaulted

Modified the Procedure I wrote for OpenCV and applied it to the VfW example.
- no additional binaries were added

-----------------------------------------------------------------------

Added a splash-screen while the webcam resolution list is built.

-----------------------------------------------------------------------

Updated:
- fix an issue with the Include files, should now run in PureBasic 5.24 LTS (x86 / x64)
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video for Windows: VfW

Post by JHPJHP »

Updated:
- 32 & 64 bit OpenCV binaries
-- v2.4.13.3 to v2.4.13.6
- SetResolution Procedure updated (alternate options REM'd out)

Context Menu:
- Save Image: save frame capture to a BMP image
- Record Video / Stop Recording: create and save an AVI video
- Resolution List >: change webcam resolution / window size
- Close Window

NB*: This is a "Video for Windows" implementation not OpenCV, but because VfW breaks down starting the webcam, I'm using OpenCV to initiate the link.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video for Windows: VfW

Post by JHPJHP »

Updated:
- tried a couple new things

I know this is old technology, but with the latest changes it seems to be a lot more stable.
- Windows 10
- PureBasic 5.73 beta 2 (x86 / x64)

NOTES:
All downloads require an access key.
Access key is emailed after a one time $20 CAD donation.
Good for all current and future scripts, programs, and updates.
Last edited by JHPJHP on Tue Aug 31, 2021 6:08 pm, edited 1 time in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video for Windows: VfW

Post by JHPJHP »

Updated:
- got rid of some useless code
- improved most Procedures
- updated the context menu
- squashed a couple bugs

Added a standalone version (vfw_capture.pb) without the OpenCV binaries; requires the \icons\ folder to compile.

NB*: Enable the debugger to display error information.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video for Windows: VfW

Post by JHPJHP »

Updated:
- improved code
- removed some redundant script
- added references\readme.txt

Both x86 and x64 versions seem to be working without having to access the dialogs, but if not, additional help can be found in references\readme.txt.

NB*: Free executables (x86/x64) can be downloaded from My PureBasic Stuff; see FREE STUFF.
Locked