Aquiring a webcam image using VBA

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,337
Office Version
  1. 2010
Platform
  1. Windows
Greets all,
i am trying to grab an image from a webcam (and ultimately an ultrasound scanner) with the user clicking a single button to aquire the image. i am guessing that i need to find a simple app that can take the snapshot and then control it using WinAPI, but im out of my depth a bit when it comes to API. if anyone has some thoughts or can point me towards a resource id be most grateful.
thx
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I do not know if you can capture from a webcam with VBA because I guess it would need a special control in a form (.dll or .OCX). I think you need to investigate what the camera & its software is capable of. You may be able to save a screenshot file.

An ordinary digital camera would be Ok because it contains files which can be accessed via a drive letter & folder.

Once you have a picture file (eg. .jpg, .bmp etc.) there would be no problem.
 
Upvote 0
Thx Brian, there is not much on line about this issue, but i am tinkering with using SHELL to issue a command line instruction to a third party app and kind of cheating, but maybe it will work out. I havent looked for an activeX solution which would be perfect. I have absolutely no idea of .ocx programing so it would have to be something i could dl. My ideal would be that i can cap and save the image and then include it on the userform without any popup interface. Thanks for your thoughts. I will keep the forum posted as to my findings.
 
Upvote 0
well heres the update...

found an ocx:
X360 Video Capture ActiveX Control

to cap image it takes 1 line of code

Me.GetCurrentImage "c:\MyImage.bmp"

easy
 
Upvote 0
You do not need a special ocx to do it that way.
Can use an ordinary image control and

Image1.Picture=LoadPicture("c:\MyImage.bmp")

You originally said "capture picture from a webcam" which is something else.
 
Upvote 0
this IS from a webcam! the ocx provides for one line acquisition of images and also caps video (which i dont need).

heres their link
http://www.x360soft.com/video-activex-ocx/x360-video-capture-activex-ocx.html

i installed the ocx and the help file is really detailed and easy to get going straight away.


from the website:
Product Description:

X360 Video Capture ActiveX Control helps application developers and programmers create applications with video capture capabilities from any video source devices (such as Digital Video(DV), web cameras or TV tuners, etc.) installed in the system. It also allows you to capture the audio from any audio source devices installed in the system. You can preview the real-time video and capture to AVI, DIVX, XVID, WMV video file formats. You can also control the output video file size such as video height and width. The ocx allows capture the current image to a bitmap file. For TV Capture, you can auto-tune the TV channels, set the country code, tuner input type, video standard and show the property page of the TV tuner.
 
Upvote 0
x360 is shareware. Please don't share commercial product solutions unless you identify them as such, the point of these boards is to help eachother devise solutions without paying for products. At least that's why I use them.

If I had money to drop whenever I had a problem I wouldn't be in these forums.
 
Upvote 0
Code:
point of these boards is to help each other devise solutions without paying for products (... etc.)
I disagree with that statement somewhat. The board has numerous purposes. I think the main one is to help us learn about Excel. As a programmer I understand what it takes in time, blood, sweat and tears to arrive at a reasonable application worth sharing. I don't think I have managed it yet.(Oh, I did once but the company I worked for got the money).

There seems to be an odd mentality with some people who always want things free. Experience shows that if a thing is worth it people will pay. As an example, however we may moan about Microsoft at times, they would not have succeeded if they produced rubbish.

Another example recently is PDF995 which enables us to make PDF files from Excel etc. There is a "free" option which has advertising. I opted to pay the peanuts they wanted to remove the advertising - not just for that reason but also to show some form of appreciation to the people who had worked long hours in a back room somewhere to work it all out.
 
Upvote 0
i do my best to report to the forum the outcome of my queries for the benefit of others reading the thread later or following the thread cos they have a similar problem but have no solution to add, which is all part of the learning experience.

there are times when i have solved problems myself where i choose not to pay for someone elses work and spend the hours to get my own solution, and then there are times when, after consultation with the forum members here, i choose not to waste any further time because it is clearly beyond my skills. just recently i saved $99 by devising a function for encrypting CODE128 barcodes.

i dont believe the forum is an advertising platform and i have never advertised any of my own projects for sale or otherwise. if you look at my earlier posts you will see that i did not disclose the name or developer of the ocx until BrianB challenged my OP.

to my way of thinking, if another member has been grappling with this problem and has not found a solution, they would probably be most grateful to hear of a work around. if they choose to trial it and dont like it, so be it, or if they decide that they want to pay, thats their perogative. i did not disclose the price of the ocx and did not embelish the product, other than observing that the help file was detailed.

n8_Mills, id be most happy to embrace your solution to this issue if you would care to post it for members to discuss.
 
Upvote 0
All right, fair enough. I'm not as patient as I could be sometimes, there's just so much bait & switch shareware that I have a very thin tolerance for the shady tactics utilized by the shills.

In any case, it's my charge to devise a solution and I'm keen on doing it. I'm probably going to aim for an Access solution since it has more of an "app" feel, but VBA tends to port well between Excel and Access, depending on the nuances.

I only just started looking today but have found some promising freeware leads by searching "the internets" for the term "vba webcam api". I'm sure you could find them too. In any case, they are mostly VB.net, not VBA, but as you have found there is a way to plug these things in to Office. I do not plan to create an ActiveX control to do so.

In any case, I'll document my progress as I feel the need to pay it forward. I am, after all, standing on the shoulders of freeware giants.
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,506
Members
449,089
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top