Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#, Emgu webcam - choose capture size

I'm using the Emgu library for integrating the open CV webcam features in C#.

I use this code for choosing the capture device and setting its size:

camera = new Capture(0);
camera.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, videoSettings.width);
camera.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, videoSettings.height);

Then I display it in an imageBox like this: imageBox1.Image = camera.QueryFrame();

Then to capture a snapshot of the current frame I use this code:

Image<Bgr, byte> snapshot = camera.QueryFrame();
snapshot.Save("snapshot.jpg");

Though I would want to be able to save the snapshot at a higher resolution than the preview window.

But the problem is that as far as I know I can't create a new "Capture" object using the same webcamera. So I'm wondering if it is maybe possible to set the camera.setCaptureProperty height and width to let's say 1028x720 but then in some way crop it for displaying it in the imageBox with the resolution of 514x360?

Or is there any other way to do this?

like image 928
jimutt Avatar asked Jul 10 '12 18:07

jimutt


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

Is C language easy?

Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.


2 Answers

I solved this by using

imageBox1.SizeMode = PictureBoxSizeMode.StretchImage;
like image 142
jimutt Avatar answered Oct 10 '22 20:10

jimutt


I solved this by using the Resize() method in QueryFrame()

currentFrame = grabber.QueryFrame().Resize(320, 240, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
like image 31
Dodo Avatar answered Oct 10 '22 19:10

Dodo