//private Size GetPreviewWindowRealSize() //{ // tDSImageSize tmpsize = new tDSImageSize(); // int m_iRelsel = 0; // int nWidth = 640, nHeight = 480; // tDSCameraCapability dscapability = new tDSCameraCapability(); // XCamera.CameraGetCapability(1, ref dscapability); // if (XCamera.CameraGetImageSizeSel(1, ref m_iRelsel, false) == emDSCameraStatus.STATUS_OK) // { // Byte[] arrtmp = new Byte[4]; // XCamera.CopyMemory(Marshal.UnsafeAddrOfPinnedArrayElement(arrtmp, 0), dscapability.pImageSizeDesc + m_iRelsel * Marshal.SizeOf(tmpsize) + 52, 4); // nWidth = BitConverter.ToInt32(arrtmp, 0); // XCamera.CopyMemory(Marshal.UnsafeAddrOfPinnedArrayElement(arrtmp, 0), dscapability.pImageSizeDesc + m_iRelsel * Marshal.SizeOf(tmpsize) + 56, 4); // nHeight = BitConverter.ToInt32(arrtmp, 0); // } // return new Size(nWidth, nHeight); //} #endregion //private void UpdateDisplayWindow() //{ // tDSImageSize tmpsize = new tDSImageSize(); // int m_iRelsel = 0; // int nWidth = 640, nHeight = 480; // tDSCameraCapability dscapability = new tDSCameraCapability(); // XCamera.CameraGetCapability(1, ref dscapability); // if (XCamera.CameraGetImageSizeSel(1, ref m_iRelsel, false) == emDSCameraStatus.STATUS_OK) // { // Byte[] arrtmp = new Byte[4]; // XCamera.CopyMemory(Marshal.UnsafeAddrOfPinnedArrayElement(arrtmp, 0), dscapability.pImageSizeDesc + m_iRelsel * Marshal.SizeOf(tmpsize) + 52, 4); // nWidth = BitConverter.ToInt32(arrtmp, 0); // XCamera.CopyMemory(Marshal.UnsafeAddrOfPinnedArrayElement(arrtmp, 0), dscapability.pImageSizeDesc + m_iRelsel * Marshal.SizeOf(tmpsize) + 56, 4); // nHeight = BitConverter.ToInt32(arrtmp, 0); // } // pictureBox.Width = nWidth; // //pictureBox.Height = nHeight - 40; // pictureBox.Height = nHeight; // pictureBox.Left = 0; // //pictureBox.Top = 24; // pictureBox.Top = 0; // //--------------------------------------------------------------------------------------------------------------------------------------- // XCamera.CameraSetDisplaySize(1, pictureBox.Width, pictureBox.Height); //} private void PreviewForm_FormClosing(object sender, FormClosingEventArgs e) { try { if (!IsCloseWithMainForm) { XCamera cam = XCamera.GetInstance(); bool isSuccessToStopCam = false; if (cam.IsActive()) { if (cam.RunMode != emDSRunMode.RUNMODE_STOP) { isSuccessToStopCam = cam.Stop(); System.Threading.Thread.Sleep(100); } if (isSuccessToStopCam && cam.UnInit()) { System.Threading.Thread.Sleep(100); OnCameraClosed(new EventArgs()); } } } } catch (System.Exception ex) { _logger.Error(ex.Message); } }
public void Init() { try { XCamera cam = XCamera.GetInstance(); XCameraCapturePara capturePara = cam.CapturePara; if (capturePara.ImageFileType == emDSFileType.FILE_JPG) { _radioGroupCaptureFileType.SelectedIndex = 0; } else if (capturePara.ImageFileType == emDSFileType.FILE_BMP) { _radioGroupCaptureFileType.SelectedIndex = 1; } else { _radioGroupCaptureFileType.SelectedIndex = 2; } _trackBarJpgFileQulity.Enabled = (_radioGroupCaptureFileType.SelectedIndex == 0); _trackBarJpgFileQulity.Value = capturePara.ImageQuality; _buttonEditPicSavePath.Text = capturePara.ImageSavePath; _spinEditMutiCaptureCnt.Value = capturePara.MutiCaptureCount; _textEditMutiCaptureTime.Text = ((double)(capturePara.MutiCaptureTimeStep) / 1000.0).ToString(); _spinEditAccuFrameCnt.Value = capturePara.FluModeAccuFrameCnt; _spinEditFrameStep.Value = capturePara.FluModeFrameStep; int videoQuality = 2; var cameraCamType = Convert.ToInt32(ConfigManager.GetAppConfig("CameraType")); if (cameraCamType == 1) { cam.GetRecordQuality(out videoQuality); _radioGroupAVIQuality.SelectedIndex = videoQuality - 1; } _buttonEditVideoSavePath.Text = capturePara.VideoSavePath; int maxVideoSize; cam.GetMaxVideoFileSize(out maxVideoSize); _spinEditMaxVideoSize.Value = maxVideoSize; if (!cam.IsActive()) { _radioGroupAVIQuality.Enabled = false; _spinEditMaxVideoSize.Enabled = false; } } catch (System.Exception ex) { logger.Error(ex.Message); } }
/// <summary> /// 开始预览视频(同时只能打开一个相机) /// </summary> /// <param name="cameraName"></param> public bool StartPreview(string cameraName) { try { bool retVal = false; XCamera cam = XCamera.GetInstance(); if (cam.IsActive()) { if (cam.RunMode != emDSRunMode.RUNMODE_STOP) { cam.Stop(); } cam.UnInit(); } _cameraCallbackProc = new XCamera.DelegateProc(SnapThreadCallback); //test if (cam.Init(_cameraCallbackProc, cameraName, _imageBox.Handle)) //if (cam.Init(_cameraCallbackProc, cameraName, _imageBack.Handle)) { if (cam.Play()) { retVal = true; //this.RealSize(); this.FitScreen(); PublishCameraOpenedEvent(new EventArgs()); } } else { retVal = false; } return(retVal); } catch (System.Exception ex) { _logger.Error(ex.Message); return(false); } }