0

我正在做一个项目,其中一部分是使用 Emgu.cv 拼接图像;要求用户导入图像。一旦用户按下“拼接”按钮,图像必须使用图片框拼接并显示为一个图像,但不是这样,而是出现了错误:

错误图像

我按照本教程尝试使用 Vb 而不是 c#:http ://www.youtube.com/watch?v=Lk37LR50viw 但该项目未构建。

按钮中的 c# 代码:

        Stitcher x = new Stitcher(false);

        Image<Bgr, Byte> result = x.Stitch(images);
        imageBox.Image = result.ToBitmap();

虽然图像是:

    Image<Bgr, Byte>[] images = new Image<Bgr, Byte>[9];

存储所有导入的图像:

        private void importbuofd_FileOk(object sender, CancelEventArgs e)
    {

        switch (x)
        {
            case 1: pictureBox1.ImageLocation = importbuofd.FileName; x = x + 1; images[0] = new Image<Bgr, Byte>(new Bitmap(pictureBox1.Image)); count++; break;
            case 2:  pictureBox2.ImageLocation = importbuofd.FileName; x = x + 1; images[1] = new Image<Bgr, Byte>(new Bitmap(pictureBox2.Image)); count++; break;
            case 3: pictureBox3.ImageLocation = importbuofd.FileName; x = x + 1; images[2] = new Image<Bgr, Byte>(new Bitmap(pictureBox3.Image)); count++; break;
            case 4: pictureBox4.ImageLocation = importbuofd.FileName; x = x + 1; images[3] = new Image<Bgr, Byte>(new Bitmap(pictureBox4.Image)); count++; break;
            case 5: pictureBox5.ImageLocation = importbuofd.FileName; x = x + 1; images[4] = new Image<Bgr, Byte>(new Bitmap(pictureBox5.Image)); count++; break;
            case 6: pictureBox6.ImageLocation = importbuofd.FileName; x = x + 1; images[5] = new Image<Bgr, Byte>(new Bitmap(pictureBox6.Image)); count++; break;
            case 7: pictureBox7.ImageLocation = importbuofd.FileName; x = x + 1; images[6] = new Image<Bgr, Byte>(new Bitmap(pictureBox7.Image)); count++; break;
            case 8:pictureBox8.ImageLocation = importbuofd.FileName; x = x + 1; images[7] = new Image<Bgr, Byte>(new Bitmap(pictureBox8.Image)); count++; break;
            case 9: pictureBox9.ImageLocation = importbuofd.FileName; x = x + 1; images[8] = new Image<Bgr, Byte>(new Bitmap(pictureBox9.Image)); count++; break;
            default: MessageBox.Show("Sorry, This is the maximum number You can import"); break;

        }
    }

我该怎么办?!

4

1 回答 1

0

尝试这个:

Image<Bgr, Byte> cam1 = _capture1.QueryFrame();
Image<Bgr, Byte> cam2 = _capture2.QueryFrame();

Image<Bgr, Byte> convert1 = new Image<Bgr, byte>(Change_Im_Size(cam1.ToBitmap(), 270, 190));
Image<Bgr, Byte> convert2 = new Image<Bgr, byte>(Change_Im_Size(cam2.ToBitmap(), 270, 190));

pictureBox1.Image = cam1.ToBitmap();
pictureBox2.Image = cam2.ToBitmap();

Image<Bgr, Byte>[] frameArray = new Image<Bgr, Byte>[2];

frameArray[0] = convert1;
frameArray[1] = convert2;

using (Stitcher stitcher = new Stitcher(false))
{
    try
    {
        Image<Bgr, Byte> result = stitcher.Stitch(frameArray);
        pictureBox3.Image = result.ToBitmap();
    }
    catch { }
}
于 2013-06-19T16:54:45.453 回答