ใน button3_click ครับ จะเขียนโคดเพื่อ save image from webcam จะ save image ที่ เป็น HSV
------------------------------------------------------------------------------------------
namespace ...
{
public partial class Form1 : Form
{
Emgu.CV.Capture capture;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
process();
}
private void process()
{
Image<Bgr, Byte> cameraImage;
cameraImage = capture.QueryFrame();
Image<Hsv, Byte> hsvImage = cameraImage.Convert<Hsv, Byte>
); //Convert RGB > HSV.
pictureBox1.Image = cameraImage.ToBitmap();
CvInvoke.cvShowImage("RGB to HSV", hsvImage);
//Create result image.
Image<Gray, Byte> ResultImage = new Image<Gray, Byte>
hsvImage.Width, hsvImage.Height);
//Define low range(16).
Image<Gray, Byte> IlowCh0 = new Image<Gray, Byte>
hsvImage.Width, hsvImage.Height, new Gray(50));
//Define hight range(30).
Image<Gray, Byte> IHiCh0 = new Image<Gray, Byte>
hsvImage.Width, hsvImage.Height, new Gray(80));
//Use cvinrange() method and hsvImage[0] = hsvimage channel 0
CvInvoke.cvInRange(hsvImage[0], IlowCh0, IHiCh0, ResultImage);
CvInvoke.cvErode(ResultImage, ResultImage, (IntPtr)null, 2); //Noise reduce.
Image<Gray, Byte> imgForContour = new Image<Gray, byte>
ResultImage.Width, ResultImage.Height);
CvInvoke.cvCopy(ResultImage, imgForContour, System.IntPtr.Zero); //Copy image for contoure
CvInvoke.cvShowImage("RGB to HSV", imgForContour );
}
private void Form1_Load(object sender, EventArgs e)
{
capture = new Emgu.CV.Capture();
}
private void button3_Click(object sender, EventArgs e)
{
}
}
}
######################################################################
รบกวนหน่อยครับ เกี่ยวกับ saving image webcam opencv C#
------------------------------------------------------------------------------------------
namespace ...
{
public partial class Form1 : Form
{
Emgu.CV.Capture capture;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
process();
}
private void process()
{
Image<Bgr, Byte> cameraImage;
cameraImage = capture.QueryFrame();
Image<Hsv, Byte> hsvImage = cameraImage.Convert<Hsv, Byte>); //Convert RGB > HSV.
pictureBox1.Image = cameraImage.ToBitmap();
CvInvoke.cvShowImage("RGB to HSV", hsvImage);
//Create result image.
Image<Gray, Byte> ResultImage = new Image<Gray, Byte>hsvImage.Width, hsvImage.Height);
//Define low range(16).
Image<Gray, Byte> IlowCh0 = new Image<Gray, Byte>hsvImage.Width, hsvImage.Height, new Gray(50));
//Define hight range(30).
Image<Gray, Byte> IHiCh0 = new Image<Gray, Byte>hsvImage.Width, hsvImage.Height, new Gray(80));
//Use cvinrange() method and hsvImage[0] = hsvimage channel 0
CvInvoke.cvInRange(hsvImage[0], IlowCh0, IHiCh0, ResultImage);
CvInvoke.cvErode(ResultImage, ResultImage, (IntPtr)null, 2); //Noise reduce.
Image<Gray, Byte> imgForContour = new Image<Gray, byte>ResultImage.Width, ResultImage.Height);
CvInvoke.cvCopy(ResultImage, imgForContour, System.IntPtr.Zero); //Copy image for contoure
CvInvoke.cvShowImage("RGB to HSV", imgForContour );
}
private void Form1_Load(object sender, EventArgs e)
{
capture = new Emgu.CV.Capture();
}
private void button3_Click(object sender, EventArgs e)
{
}
}
}
######################################################################