Пример #1
0
        private void ButtonAnalysisImage_Click(object sender, EventArgs e)
        {
            CImage image = new CImage();

            if (false == SDK.CvtBitmap2CImage(m_Bitmap, ref image))
            {
                MessageBox.Show("CvtBitmap2CImage出错!");
                return;
            }

            BUAnalysisResult result = new BUAnalysisResult();

            error_code = SDK.ExecuteBUAnalysisFromImage(hAnalysisHandle, image, ref result);
            if (error_code != ErrorCode.SYY_NO_ERROR)
            {
                MessageBox.Show("运行分析出错,请查看log文件。");
                return;
            }

            error_code = SDK.DrawResult2Image(ref image, result);
            if (error_code != ErrorCode.SYY_NO_ERROR)
            {
                MessageBox.Show("运行转换出错,请查看log文件。");
                return;
            }


            ShowImage(image);
        }
Пример #2
0
        private void OkCardCaptureThread()
        {
            ErrorCode        error_code;
            BUAnalysisResult result = new BUAnalysisResult();
            CImage           image  = new CImage();

            ulong hHandle = 0;

            error_code = SDK.InitBUAnalysis(ref hHandle);
            if (error_code != ErrorCode.SYY_NO_ERROR)
            {
                MessageBox.Show("初始化模型出错,请查看log文件。");
                return;
            }

            while (m_bIsCapture)
            {
                error_code = OkCardSDK.CaptureImage(hOkCardSDKHandle, ref image);
                if (error_code != ErrorCode.SYY_NO_ERROR)
                {
                    MessageBox.Show("初始化ok卡失败.");
                    break;
                }

                if (m_bIsAnalysisOkCardCapture)
                {
                    error_code = SDK.ExecuteBUAnalysisFromImage(hHandle, image, ref result);
                    if (error_code != ErrorCode.SYY_NO_ERROR)
                    {
                        MessageBox.Show("运行分析出错,请查看log文件。");
                        break;
                    }

                    error_code = SDK.DrawResult2Image(ref image, result);
                    if (error_code != ErrorCode.SYY_NO_ERROR)
                    {
                        MessageBox.Show("运行转换出错,请查看log文件。");
                        break;
                    }
                }

                Bitmap cvt_bitmap = new Bitmap(image.nWidth, image.nHeight, image.nChannels * image.nWidth,
                                               System.Drawing.Imaging.PixelFormat.Format32bppRgb, image.pData);

                cvt_bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
                ShowImage(cvt_bitmap);
                Thread.Sleep(33);
            }

            m_bIsCapture = false;
            m_bIsAnalysisOkCardCapture = false;
            SDK.ReleaseBUAnalysis(ref hHandle);
            OkCardSDK.Release(ref hOkCardSDKHandle);
        }
Пример #3
0
        private void CaptureVideoThread()
        {
            ErrorCode        error_code;
            BUAnalysisResult result = new BUAnalysisResult();

            ulong hHandle = 0;

            error_code = SDK.InitBUAnalysis(ref hHandle);
            if (error_code != ErrorCode.SYY_NO_ERROR)
            {
                MessageBox.Show("初始化模型出错,请查看log文件。");
                return;
            }

            while (true)
            {
                error_code = SDK.GetVideoFrame(hVideoHandle, ref m_videoFrame);
                if (error_code != ErrorCode.SYY_NO_ERROR)
                {
                    if (error_code == ErrorCode.SYY_SYS_ERROR)
                    {
                        MessageBox.Show("获取视频帧失败.");
                    }
                    if (error_code == ErrorCode.SYY_VIDEO_END_FRAME)
                    {
                        MessageBox.Show("视频帧已读取完.");
                    }

                    break;
                }

                error_code = SDK.ExecuteBUAnalysisFromImage(hHandle, m_videoFrame, ref result);
                if (error_code != ErrorCode.SYY_NO_ERROR)
                {
                    MessageBox.Show("运行分析出错,请查看log文件。");
                    break;
                }

                error_code = SDK.DrawResult2Image(ref m_videoFrame, result);
                if (error_code != ErrorCode.SYY_NO_ERROR)
                {
                    MessageBox.Show("运行转换出错,请查看log文件。");
                    break;
                }

                Bitmap cvt_bitmap = new Bitmap(m_videoFrame.nWidth, m_videoFrame.nHeight, m_videoFrame.nChannels * m_videoFrame.nWidth,
                                               System.Drawing.Imaging.PixelFormat.Format24bppRgb, m_videoFrame.pData);

                ShowImage(cvt_bitmap);
                Thread.Sleep(33);
            }

            SDK.ReleaseBUAnalysis(ref hHandle);
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (m_sImageFile == "" || false == File.Exists(m_sImageFile))
            {
                MessageBox.Show("文件路径有误: " + m_sImageFile);
                return;
            }

            if (m_Bitmap == null)
            {
                MessageBox.Show("没加载bitmap!");
                return;
            }

            string path = System.Environment.CurrentDirectory;

            CImage image = new CImage();

            if (false == SDK.CvtBitmap2CImage(m_Bitmap, ref image))
            {
                MessageBox.Show("CvtBitmap2CImage出错!");
                return;
            }

            BUAnalysisResult result = new BUAnalysisResult();

            error_code = SDK.ExecuteBUAnalysisFromImage(hHandle, image, ref result);
            if (error_code != ErrorCode.SYY_NO_ERROR)
            {
                MessageBox.Show("运行分析出错,请查看log文件。");
                return;
            }

            error_code = SDK.DrawResult2Image(ref image, result);
            if (error_code != ErrorCode.SYY_NO_ERROR)
            {
                MessageBox.Show("运行转换出错,请查看log文件。");
                return;
            }

            Bitmap cvt_bitmap = new Bitmap(image.nWidth, image.nHeight, image.nChannels * image.nWidth,
                                           System.Drawing.Imaging.PixelFormat.Format24bppRgb, image.pData);

            ShowImage(cvt_bitmap);
        }
Пример #5
0
        private void CaptureVideoThread()
        {
            ErrorCode        error_code;
            BUAnalysisResult result = new BUAnalysisResult();
            CImage           temp   = new CImage();

            ulong hHandle = 0;

            error_code = SDK.InitBUAnalysis(ref hHandle);
            if (error_code != ErrorCode.SYY_NO_ERROR)
            {
                MessageBox.Show("初始化模型出错,请查看log文件。");
                return;
            }

            int frameCount = 0;

            while (m_bIsCapture)
            {
                frameCount += 1;

                error_code = SDK.GetVideoFrame(hVideoHandle, ref m_cVideoFrame);
                if (error_code != ErrorCode.SYY_NO_ERROR)
                {
                    if (error_code == ErrorCode.SYY_SYS_ERROR)
                    {
                        MessageBox.Show("获取视频帧失败.");
                    }
                    if (error_code == ErrorCode.SYY_VIDEO_END_FRAME)
                    {
                        MessageBox.Show("视频帧已读取完.");
                    }

                    break;
                }


                if (m_nSkipFrameNum > 0)
                {
                    if (frameCount % (m_nSkipFrameNum + 1) != 0)
                    {
                        continue;
                    }
                }

                error_code = SDK.ExecuteBUAnalysisFromImage(hHandle, m_cVideoFrame, ref result);
                if (error_code != ErrorCode.SYY_NO_ERROR)
                {
                    MessageBox.Show("运行分析出错,请查看log文件。");
                    break;
                }

                error_code = SDK.DrawResult2Image(ref m_cVideoFrame, result);
                if (error_code != ErrorCode.SYY_NO_ERROR)
                {
                    MessageBox.Show("运行转换出错,请查看log文件。");
                    break;
                }

                Bitmap show_bitmap = (new Bitmap(m_cVideoFrame.nWidth, m_cVideoFrame.nHeight, m_cVideoFrame.nChannels * m_cVideoFrame.nWidth,
                                                 System.Drawing.Imaging.PixelFormat.Format24bppRgb, m_cVideoFrame.pData));

                ShowImage(show_bitmap);
                Thread.Sleep(m_nSleepNum);

                temp          = m_cFrameShow;
                m_cFrameShow  = m_cVideoFrame;
                m_cVideoFrame = temp;
            }

            m_bIsCapture = false;
            SDK.ReleaseBUAnalysis(ref hHandle);
            SDK.ReleaseVideo(ref hVideoHandle);
        }