Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3143
  • Last Modified:

Capture from WebCam in OCX, then Save as Portrait Photo.

Hello,

I am in desperate need of this question answering (hence the amount of points attached to this question... if i could offer more, believe me i would!!)

I am using the ezvidcap ocx (http://www.shrinkwrapvb.com/ezvidc60.zip) with vb6 - this works amazingly with the webcam and everything you need is included - it'll take a photo, save etc... but as with most webcam software it saves at a resolution of: 320 x 240...

What i want to do is take this image, but only take the middle of the image, making the image size: 192 x 240... like a passport photo and then save it as a JPG... that'd be amazing!!

I know this is very possible - i know people have done it before, but i can not find the resources to help me out :o(

If anyone can help, i'll be so so greatful!!

UKKrew.

0
ukkrew
Asked:
ukkrew
  • 13
  • 13
  • 2
  • +1
1 Solution
 
fadlounCommented:
Nice OCX ,,,,, I was looking for afreeware like this .
I am gonna to download it ,,,, your target same mine.
if I get anything help I will come back to you
regards
0
 
ukkrewAuthor Commented:
:) i've got it to display the right size on screen... but its just saving the photo... everything looks perfect on the screen - once it can save the right size i'll be sorted :)

UKKrew.
0
 
sgayatriCommented:
Kodak Image edit control solves your problem.
Add the component from components option of project menu
Add two image controls to your form say
imgedit1 , imgedit2
Add command button to your form
command1
customize the following code to your needs

private sub command1_click()

imgedit1.image="yourphoto.tif"
imgedit2.image="blank.tif"
''it is required to display a blank file on the  
''edit control;so you can scan a blank page    
''save it as blank.tif and display blank page

imgedit1.display
imgedit2.display

imgedit1.drawselectionrect  10,10,1000,1000

''' You find out the values for the  
           
''''selection

imgedit1.clipboardcopy
imgedit2.clipboardpaste

-------------------------------------------------
This control is very flexible; you may still explore the other possibilities to customize your need
end sub

Good Luck!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ukkrewAuthor Commented:
the quality of an image when saved via the kodak ocx appears to be pretty poor compared to the usual windows save - does anyone know why this is?

UKKrew.
0
 
sgayatriCommented:
The picture settings while taking photograph will be preserved as they are when the picture is taken from webcam. So pl first check the settings like resolution, brightness etc of the picture being taken.

You can save the picture with imgedit control by giving options like

imgedit1.savepage FILENAME, FILETYPE, PAGETYPE, COMPRESSIONTYPE, COMPRESSIONINFO,SAVEATZOOM,PAGENUMBER

You get full help on imgedit control. At design time, Click the imgedit control. Press F1 key.


0
 
x50FadeCommented:
ukkrew

I know your frustration.... I also developed an app that uses the webcam...but alas after searching the internet for many days, I could not get a working, viable solution for saving my images as a jpg file.

Then....one glorious day I said what the hec...and I bought VB.net. Now I still use vb 6.0 alot, but I found something kewl in .NET that I was allways looking for in VB 6.0. VB.NET can save pictures from the picturebox control as JPG's and GIF's !!!! Yippee.

My VB app still saves pics as BMP, but not wanting to re-create my VB 6 app in .NET I merely used .NET to write a simple routine that scans a specified directory, checks for files that are not allready JPG, opens them in the Picturebox control and saves them as JPG's and then deletes the original BMP file.

I don't know if you have .NET, cause then I could give you the source, otherwise I could give you the exe but that would mean that you won't be able to customise it as needed?

Hope this helps

Cheers
0
 
ukkrewAuthor Commented:
x50Fade, that sounds brilliant - we had our copies of .net delivered on monday, i've just not got around to installing it yet... is there a way in .net to crop the image too?

Thanks :o)
0
 
x50FadeCommented:
I have not yet looked at that as yet....but I'm sure there is.

Although .NET can convert my old VB 6 apps to .NET, there are allways a few things that does not come through...
.NET is quite kewl and most of my new stuff I will definately do in .NET.

Check it out
0
 
x50FadeCommented:
If I may ask...what are you trying to do?

Are you taking Passport like photos of people( Or something ), or do you just want to save a little section of the picture...

If you are trying to create a passport like picture of someone....I've allways just set the picturebox size to whatever size I want my caption to be...then the picbox obviously does not display everything that the Webcam sees, but as you position the webcam, you can actually focus someone's "Head-Shot" in the picbox and then save it.

***************
*            *            *
*          *   *         *
*           **           *
*                          *
*                          *
*                          *
***************

*******
*    *    *
* *   *  *
*   **   *
*******

Hope this makes sense...and hope it helps

P.S. B.T.W > VB.net works much different with graphics than VB 6.0.....it's quite a steep learning curve...
0
 
ukkrewAuthor Commented:
What i'm trying to do is take an image provided by a video capture device and save it as as a passport photo for our staff database and id card system... currently i'm having to aquire the photo in some bundled software which came with the capture device which is saved as (320 x 240) then save this photo as a bmp (as it doesnt support jpg's) then load the saved image into paint shop pro, crop it to the right size (192x240) and convert it to a jpg and save the filename with the staff id number... the whole process is painfully slow!!

I found an OCX on the internet (http://www.shrinkwrapvb.com/ezvidc60.zip) when i first saw this i thought... wow, i mean my application reads in the member of staff's id number from the database, it can capture an image in the same application & save it with the right filename... just it saves as a BMP & at the size of 320 x 240. Once saved i still have to load it into paint shop pro, resize the image and save as a jpg... then re-launch the vb application i coded as it links to a crystal report which will dynamically add the staff image to a report which in turn will print the staff id card!

As you can see there is just one last step to complete before i have a fully working application, i just need vb to take the image, crop it to the correct size, save it as a JPG and then i'm away!!

Any help you can provide would be brilliant, i've been working on this project for too long, and dont really want to get stopped at this hurdle!!

Thanks once again,

Aidan :o)
0
 
x50FadeCommented:
Did you understand my previous post......scaling the picbox so that let's say..one 1/4(whatever size) of the camera view is displayed (the rest is hidden, not visible), and moving the camera till you can see the person's face....

Saving the file then will save only the visible area of the picbox, giving you a nice photo....

B.T.W. Why are you not using BMP's, size too big?
0
 
ukkrewAuthor Commented:
hehehe yes, i understood - i was just giving you the full story of the situation.

how would i do this then... as i have to save as the 320x240 bmp first, then i guess i'll need to read it back into a picture box... but how do i make sure the picture box is looking at the right area...

below is an example of what i'm after... i basically need to trim 64pixels off the left & right leaving a picture 192x240, and if possible i do not want the end user to see this stage, i guess its possible to turn visibility off and code it to open, save etc, its just saving the right area..?

===================================
=     64     =                   192                   =     64     =
=     64     =                   192                   =     64     =
=     64     =                   192                   =     64     =
=     64     =                   192                   =     64     =
=     64     =                   192                   =     64     =
=     64     =                   192                   =     64     =
=     64     =                   192                   =     64     =
=     64     =                   192                   =     64     =
=     64     =                   192                   =     64     =
=     64     =                   192                   =     64     =
=     64     =                   192                   =     64     =
===================================

... do you see what i mean? Its a tough one!!

Aidan.
0
 
x50FadeCommented:
OK....many ways to accomplish this....but I don't think you're getting my drift here...

1). Do you have control of the software that captures the pics, i.e. are YOU coding the capture of the images?
2). Will this app run on the user's machine, or an 1 machine that captures a person, does the whole card thing...next person.

I am battling to understand just how you want to use this app?

My APP.

1). Student enters
2). PC operator opens app, aims WebCam till he get's sufficient picture, clicks "Capture Photo" button
3). Photo get's captured/saved (allready the correct size, cause PicBox has been scaled to predefined size in design mode)
Optional step 4). Pic gets converted to JPG before saved to DB

Please elaborate.....damn we would understand each other so much better if we could talk...lol
0
 
x50FadeCommented:
If you want to give me your e-mail addy, I can better explain with some help from Photoshop...send you 2 pics to explain what I am proposing....

B.T.W. I also know of another solution that *might* work, but the current suggestion is by far the easiest and more painless solution..I think
0
 
ukkrewAuthor Commented:
ok... what you have is the solution i'm after...

My current APP.
1) new staff / new student enters
2) if student or staff, pc operator pulls up the staff / student management application
3) user clicks capture photograph
4) behind the scenes, the staff / student management system creates a mdb database then calls the application (to capture photos) to launch.
5) PC operator aims WebCam till he get's sufficient picture, clicks "Capture Photo" button - at this stage i am using an ocx to capture the photo (the one listed) sadly i do not have that much control over this ocx as its encoded... but it does come with a prebuilt function to save it at the size of 320x240 which i am currently doing.
6) behind the scenes, vb saves the picture with the student / staff id number, then closes its self (collected from database)
7) PC operator manually opens this photo in paint shop pro and crops it to the size of 192x240, then re-saves the file as a JPG in the photos folder
8) operator now has to re-launch the application via the student / staff management application (so that the photo is displayed on screen)
9) pc operator clicks button to print id card (from here it works)


My Model APP.
1) new staff / new student enters
2) if student or staff, pc operator pulls up the staff / student management application
3) user clicks capture photograph
4) behind the scenes, the staff / student management system creates a mdb database then calls the application (to capture photos) to launch.
5) PC operator aims WebCam till he get's sufficient picture, clicks "Capture Photo" button
6) Photo is saved in network photo folder as a JPG at the size 192x240 with student / staff id as the filename
7) The current photograph picture box will refresh as the saved photo can be seen
8) pc operator clicks button to print id card (from here it works)


- how are you capturing photos, we use an ocx so that the pc operators can see exactly what is going to be captured before clicking capture.

... does this make more sense?

Aidan.
0
 
ukkrewAuthor Commented:
you can contact me on: ukkrew@hammond.me.uk

many thanks :o)
0
 
x50FadeCommented:
Ahhh....But you see, I am doing the capturing myself....with sme help from a DLL(Normal dll that get's installed with every webcam)....by the way, I'm almost sure I can specify the size of the stream being captured.

Anyhows, I will quickly mail you some pics...then we can get onto how to do it my way.
0
 
ukkrewAuthor Commented:
sorry i didnt get back to you - i've been having internet problems this afternoon, i've just downloaded the file you sent me :o)
0
 
x50FadeCommented:
Funny..I also had some internet problems...ADSL is still extremely slow.....Aarggghhhhh
0
 
ukkrewAuthor Commented:
Ok, i'm back - my downtime was due to bad weather :o(

Anyway (back on topic), i recieved the file you sent... the bit i'm still confused with is how to save just a section of that image - i had a look in the source code and changed a few values bits but it didnt work. How have you made it so that it only saves an area of the picture?

:o)
0
 
x50FadeCommented:
Just resize the picbox to what you want, start up the app, and capture....
0
 
ukkrewAuthor Commented:
it doesnt work... it still saves the pictures at 320 x 240, regardless of the size of the box on the screen :o(
0
 
x50FadeCommented:
Picture1.Picture = Picture1.Image
SavePicture Picture1.Picture, "c:\temp.bmp"
0
 
ukkrewAuthor Commented:
Ah i see where you are coming from now (thank you so much for all the help so far)... i tried putting that code into the source you sent me (changing the names as on my form) but i get the error:

method or data member not found?

Any ideas?
0
 
x50FadeCommented:
Where do you get the error?

How far does it go...do you actually get it to capture?
0
 
ukkrewAuthor Commented:
i get the preview image in the box powered by the dll... then i've added the image box, i cant get one into the other... the dll box just flashes when i click the capture button, nothing is saved.
0
 
x50FadeCommented:
No no no no...........hehe

Use just one picture box...all we are doing is assigning whatever is visible in the Picturebox (It's physical Image at that time), to it's picture propperty, so it can be saved.....

Private Sub cmd_Capture()
   Picture1.Picture = Picture1.Image
   SavePicture Picture1.Picture, "c:\temp.bmp"
End Sub
0
 
ukkrewAuthor Commented:
x50Fade, you are the MAN!

I took the past few hours to install this visual studio .net - i have it up and running now, but the environment is really different compared to the vb6 i'm used to - it comes up with a build error everytime i try and test out the project (after upgrading from vb6 to vb.net)?

The reason i am trying to get it into vb.net is because you told me about the graphics and being able to save them as .jpg's

Thanks for all the time you have spared to help me out!!

UKKrew.
0
 
x50FadeCommented:
Ja, I also could not get it working propperly in .NET.....a lot of stuff is different...that's why I only wrote the app that scans, loads and converts the files every now and again in VB.NET, and I envoke it from my VB6 app
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 13
  • 13
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now