Click here to Skip to main content
15,882,504 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more: , +
I have a problem with my project ,

I think it's about web camera/ camera problem ,

I have developed my application ,and i have test on my pc ,

it was successfully when i am using my camera,

then i try to use webcam it was not move to webcam ,and still using my camera ,

What I have tried:

this is my code

using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Media;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AplikasiAbsen16082020
    public partial class Form1 : Form
        Capture camera;
        Image<Bgr, Byte> currentFrame;
        List<Image<Gray, byte>> trainingimages = new List<Image<Gray, byte>>();
        public Form1()
            face = new HaarCascade("haarcascade_frontalface_default.xml");
        private void Form1_Load(object sender, EventArgs e)
                camera = new Capture(1);
                Application.Idle += new EventHandler(FrameGrabber);

        private void FrameGrabber(object sender, EventArgs e)
                currentFrame = camera.QueryFrame().Resize(440, 330, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
                gray = currentFrame.Convert<Gray, Byte>();
                camera.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 640.01);
                camera.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 480.01);
                imageBox1.Image = currentFrame;            

is there any way how to connect my application into webcam
BillWoodruff 7-Sep-20 3:04am    
With code that does not show how you attempt to connect to the camera, and does not show definitions of variables like 'face ... how are we supposed to assist you ?
Member 14760154 7-Sep-20 22:02pm    
camera = new Capture(1);

with this code
BillWoodruff 8-Sep-20 0:56am    
With code that does not show definitions of variables like 'face ... how are we supposed to assist you ?
F-ES Sitecore 7-Sep-20 5:56am    
This code won't compile so I don't understand how you can have had it working. It looks like code you've copied from somewhere else without actually understanding. The issue might be

camera = new Capture(1);

that will get a reference to the second camera device attached. If you're trying this code on a different machine with different number\configuration of cameras then "1" might not longer refer to the camera you want, it might be "0" or some other number.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900