C#-EMGU.CV-------video interception and image processing basics

Source: Internet
Author: User

IMAGE<BGR, byte> frame = capture. Queryframe ()//Get the video frame of the camera
IMAGE<BGR, byte> frame2 = frame. CONVERT<BGR, byte> (); Converts a frame to an RGB type, which corresponds to a three-dimensional array
Image<gray, byte> grayframe = frame. Convert<gray, byte> ()//Convert frame to Gray type, corresponding to one-dimensional array
IMAGE<YCC, byte> currentycrcbframe = frame. CONVERT<YCC, byte> ()//Convert frame to YCBCR type, corresponding to three-dimensional array
Image<gray, byte> skin = new Image<gray, byte> (frame. Width, frame. Height);//Build Grayscale Area objects

int rows = frame. Rows;
int cols = frame. Cols;
Byte[,,] bgrdata= frame2. Data;

for (int i = 0; i < rows; i++)
for (int j = 0; J < cols; J + +)
{
b = Bgrdata[i, j, 0];
g = Bgrdata[i, J, 1];
R = Bgrdata[i, J, 2];
if (b < 110)
{
Bgrdata[i, j, 0] = (byte) 0;
Bgrdata[i, j, 1] = (byte) 0;
Bgrdata[i, J, 2] = (byte) 0;
}
else//two-valued
{
Bgrdata[i, j, 0] = (byte) 255;
Bgrdata[i, j, 1] = (byte) 255;
Bgrdata[i, J, 2] = (byte) 255;
}

}
pictureBox1.Image = frame2. Flip (Emgu.CV.CvEnum.FLIP.NONE). Tobitmap (); After conversion, display a binary image on the picture.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.