コード例 #1
0
        private void buttonBeginRecord_Click(object sender, EventArgs e)
        {
            if (m_Grabber == IntPtr.Zero)
            {
                return;
            }

            if (m_bRecording)
            {
                m_bRecording = false;

                if (MvApi.CameraStopRecord(m_hCamera) == 0)
                {
                    MessageBox.Show("录像保存成功");
                }
                else
                {
                    MessageBox.Show("录像保存失败");
                }

                this.buttonBeginRecord.Text = "开始录像";
                this.Text = "录像";
            }
            else
            {
                String SavePath = this.textBoxRecordPath.Text;
                if (SavePath.Length < 1)
                {
                    MessageBox.Show("请先选择录像文件的保存路径");
                    return;
                }

                // 压缩格式3:需要安装DivX编码器
                CameraSdkStatus status     = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
                int[]           FormatList = new int[] { 3, 0 };
                foreach (int Fmt in FormatList)
                {
                    status = MvApi.CameraInitRecord(m_hCamera, Fmt, SavePath, 0, 100, 30);
                    if (status == 0)
                    {
                        break;
                    }
                }
                if (status != 0)
                {
                    MessageBox.Show("启动录像失败");
                    return;
                }

                m_bRecording = true;
                this.buttonBeginRecord.Text = "停止录像";
                this.Text = "录像(录像中。。。)";
            }
        }
コード例 #2
0
        private CameraSdkStatus buttonBeginRecord_InitACameraRecord(CameraHandle m_hCamera, string SavePath)
        {
            CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;

            int[] FormatList = new int[] { 3, 1, 0 };
            foreach (int Fmt in FormatList)
            {
                status = MvApi.CameraInitRecord(m_hCamera, Fmt, SavePath, 0, 100, 30);
                if (status == 0)
                {
                    break;
                }
            }
            return(status);
        }