Note that there are some explanatory texts on larger screens.

plurals
  1. POReleasing memory by the resource
    primarykey
    data
    text
    <p>I have a program in c# which uses my local webcam, to capture and store images. I have buttons to click on start,stop,continue n etc.When I run the program it works properly for the first time after I turn my system on, but in the consecutive executions of the same thing I get an error (in pop-up window):</p> <blockquote> <p>An error occurred while capturing the video image. The video capture will now be terminated. Object reference not set to an instance of the object.</p> </blockquote> <p>for which I assume that it might be because of the camera device, not releasing the memory it used. So how do I programatically free it up, when I click on the exit button? Below is part of the program and i get error in the webcam.start(0) method</p> <p>namespace WinFormCharpWebCam {</p> <pre><code>class WebCam { private WebCamCapture webcam; private System.Windows.Forms.PictureBox _FrameImage; private int FrameNumber = 30; public void InitializeWebCam(ref System.Windows.Forms.PictureBox ImageControl) { webcam = new WebCamCapture(); webcam.FrameNumber = ((ulong)(0ul)); webcam.TimeToCapture_milliseconds = FrameNumber; webcam.ImageCaptured += new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured); _FrameImage = ImageControl; } void webcam_ImageCaptured(object source, WebcamEventArgs e) { _FrameImage.Image = e.WebCamImage; } public void Start() { webcam.TimeToCapture_milliseconds = FrameNumber; webcam.Start(0); //error pops up when the execution comes to this method } public void Stop() { webcam.Stop(); } public void Continue() { // change the capture time frame webcam.TimeToCapture_milliseconds = FrameNumber; // resume the video capture from the stop webcam.Start(this.webcam.FrameNumber); } public void ResolutionSetting() { webcam.Config(); } public void AdvanceSetting() { webcam.Config2(); } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload