[英]How to Save the Captured Image from Webcam into Project Folder/Specific Folder
I'm trying to save the picturebox image that has been captured using the Webcam. 我正在尝试保存使用网络摄像头捕获的图片框图像。 I'm using AForget.NET.
我正在使用AForget.NET。
What i want to do is I want that picturebox image to be saved into Project/Specific Folder when i click Ok button and get that path that has been save to folder. 我想要做的是当我单击确定按钮并获取已保存到文件夹的路径时,我希望将该图片框图像保存到项目/特定文件夹中。
I'm getting error of GDI + 我收到了GDI +的错误
Here's my Code 这是我的代码
RegisterCustomer _regCustomer;
public UpdateImageCapture(RegisterCustomer regCustomer)
{
InitializeComponent();
_regCustomer = regCustomer;
}
ImageHelper img = new ImageHelper();
private void ImageCapture_Load(object sender, EventArgs e)
{
img.ImageSettings
(
img._captureDevice,
img.finalFrame,
cboxWebcamType
);
img.finalFrame.NewFrame += new NewFrameEventHandler(FinalFrame_NewFrame);
btnOk.Hide();
btnCancel.Hide();
}
private void FinalFrame_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
picPreviewImage.Image = (Bitmap)eventArgs.Frame.Clone();
}
These code specify that when the button capture is clicked the picCaptureImage(Picturebox2) will get the clone copy of picPreviewImage(Picturebox1) 这些代码指定当单击按钮捕获时,picCaptureImage(Picturebox2)将获得picPreviewImage(Picturebox1)的克隆副本
NOTE: Picturebox1 show yourself from a webcam 注意:Picturebox1通过网络摄像头展示自己
private void BtnCapture_Click(object sender, EventArgs e)
{
picCapturedImage.Image = (Bitmap)picPreviewImage.Image.Clone();
picCapturedImage.BringToFront();
btnCapture.Hide();
btnOk.Show();
btnCancel.Show();
}
private void BtnOk_Click(object sender, EventArgs e)
{
if (picCapturedImage.Image != null)
{
var bitmap = new Bitmap(picCapturedImage.Image);
var newBitmap = new Bitmap(bitmap);
bitmap.Save(@"C:\Users\dieth\source\repos\SalesInventorySystem\SalesInventorySystem\Resources", ImageFormat.Png);
bitmap.Dispose();
bitmap = null;
}
else {
MessageBox.Show("NULL");
}
}
I solved it , but when i tried to capture an image again , it just replacing the image from that file. 我解决了它,但当我试图再次捕获图像时,它只是替换该文件中的图像。
if (picCapturedImage.Image != null)
picCapturedImage.Image.Save(@"..\..\Resources\ImageCapture.Png", ImageFormat.Png);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.