Home > Net >  C # objects being used can't call
C # objects being used can't call

Time:09-28

1) openCVsharp call two cameras to read the image
(2) the countdown to trigger the save image
(3) save prompt object being used is not able to use the problem
 
Private void CaptureRead (VideoCapture capture, PictureBox picture, ENM_CAPTURE ENM_CAPTURE)
{
//first define face_token represented as an empty
//face detection
Using (Mat frame=new Mat ())
{
int i=0;
while (! Canel)
{
Try
{
if (! The capture capture. IsOpened ()). The Open ((int) eNM_CAPTURE);

//read image information
If (the capture. Read (frame))
{
If (frame. The Empty ()) return;

Picture. The Image=Image. FromStream (new MemoryStream (frame) ToBytes ()));

Thread.sleep (60);

i++;
}
}
The catch (Exception ex)
{
BaseLogger. Error (ex. Message);
continue;
}
}
}
}

 
Using (var img=pictureBox2. Image)
{
M_IMG iMG1=new M_IMG ();
"IMG1. Im_name=${montion. Id} _F_ {_SN. Sn}. JPG";
IMG1. Im_base64=ImageBase64 (img);
_SN. Images. The Add (iMG1);
}
Using (var img=pictureBox3. Image)
{
M_IMG iMG2=new M_IMG ();

IMG2. Im_name=${" montion. Id} _S_ {_SN. Sn}. JPG ";
IMG2. Im_base64=ImageBase64 (img);
_SN. Images. The Add (iMG2);
}

 
Private string ImageBase64 Image (img)
{
Byte [] arr=null;
Try
{
Using (MemoryStream ms=new MemoryStream ())
{
Img. Save (ms, System. Drawing. Imaging. ImageFormat. Jpeg);
Arr=new byte [Ms. Length];
Ms. Position=0;
Ms. Read (arr, 0, (int) Ms. Length);
Ms. Close ();
}
}
The catch (Exception ex)
{
BaseLogger. Error (ex. Message);
AutoClosingMessageBox. Show (ex. The Message, "error", 3000);
}
Return the Convert. ToBase64String (arr);
}

CodePudding user response:

Picture. The Image=Image. FromStream (new MemoryStream (frame) ToBytes ()));

This sentence, can let the object always occupy the picture flow:
Solution: (the following is my solution in WPF, according to oneself circumstance you solve)

Convection object to read after flow, a Clone, and then use the copy assignment interface controls:

Image Image=Image. FromFile (x.F ullName);
Image x1=(Image) (Image. The Clone ());

Image. The Dispose ();//release the original file

//after the x1, completed, to release the x1, as shown in I used in WPF

  •  Tags:  
  • C#
  • Related