void CMainFrame::on_video_cap() { if(theApp.m_CCD.m_isinit&&theApp.m_CCD.m_runstatus!=RUNMODE_STOP) { if(theApp.m_CCD.m_path2save==_T("")) { MessageBox(_T("保存路径为空,请选择一个文件夹保存图片"),_T("错误"),MB_ICONERROR); return; } string filename; string strpath=theApp.m_CCD.m_path2save; DS_FILE_TYPE imagetype=FILE_JPG; //Csettings *setting=Csettings::getInstance(); //setting->get_image_attr(strpath,imagetype); if(strpath.rfind('\\')!=strpath.size()-1) strpath+="\\"; CString cstr; cstr.Format("%d",(int)theApp.m_vsgui.m_wl_curr); filename=strpath+"image_"+cstr.GetBuffer(); DS_CAMERA_STATUS err=STATUS_OK; if((err=CameraCaptureFile(filename.c_str(),theApp.m_CCD.m_image_type))!=STATUS_OK) { //cstr.Format(_T("error code = %d"),err); //MessageBox(cstr.GetBuffer()); } //cstr.Format("err=%d",err); //MessageBox(cstr.GetBuffer()); } }
UINT __cdecl video_cap_func(LPVOID arg) { string filename; string strpath=theApp.m_CCD.m_path2save; //DS_FILE_TYPE imagetype=FILE_JPG; //Csettings *setting=Csettings::getInstance(); //setting->get_image_attr(strpath,imagetype); if(strpath.rfind('\\')!=strpath.size()-1) strpath+="\\"; CString cstr; //cstr.Format(_T("path = %s"),strpath.c_str()); //MessageBox(theApp.m_pMainWnd->GetSafeHwnd(),cstr.GetBuffer(),_T("提示"),MB_OK); float wl_min_cap=(float)theApp.m_vsgui.m_wl_min_cap; float wl_max_cap=(float)theApp.m_vsgui.m_wl_max_cap; float wl_step=(float)theApp.m_vsgui.m_wl_step; //DS_FILE_TYPE image_type=theApp.m_CCD.m_image_type; for(int i=0;wl_min_cap+i*wl_step<=theApp.m_vsgui.m_wl_max_cap;++i) { if(!g_syncflag) break; for(int j=0;j!=theApp.m_vsgui.m_wl_cap_times;++j) { VsSetWavelength(theApp.m_vsgui.m_vshwnd,wl_min_cap+i*wl_step,TRUE); //Sleep(200); //Sleep(theApp.m_CCD.m_exposuretime*10); Sleep(300); cstr.Format("%d",(int)(wl_min_cap+i*wl_step)); filename=strpath+cstr.GetBuffer(); CameraCaptureFile(filename.c_str(),theApp.m_CCD.m_image_type); //Sleep(theApp.m_CCD.m_exposuretime*100); //Sleep(200); Sleep(200); if(!g_syncflag) break; } } if(g_syncflag) VsSetWavelength(theApp.m_vsgui.m_vshwnd,theApp.m_vsgui.m_wl_curr,TRUE); //Sleep(1000); //MessageBox(theApp.m_pMainWnd->GetSafeHwnd(),_T("连拍结束"),_T("提示"),MB_OK); //cstr.Format(_T("path = %s"),strpath.c_str()); //MessageBox(theApp.m_pMainWnd->GetSafeHwnd(),cstr.GetBuffer(),_T("提示"),MB_OK); g_syncflag=FALSE; Sleep(50); //HWND hwnd=FindWindow(_T("CCapPsrogressDlg"),_T("连拍中")); //HWND hwnd=FindWindow(_T("CCapProgressDlg"),NULL); HWND hwnd=FindWindow(NULL,_T("连拍中")); //cstr.Format(_T("hwnd = %d"),hwnd); //MessageBox(theApp.m_pMainWnd->GetSafeHwnd(),cstr.GetBuffer(),_T("提示"),MB_OK); if(hwnd!=NULL) SendMessage(hwnd,WM_CLOSE,NULL,NULL); return 0; }
/*============================================================== Name: OnSaveImage Desc: save the image Param: Return: Note: save the image for calibration //the default here is exe file path... 这里可以选择存储某一时间的图片,图片格式通过setup选择 --------------------------------------------------------------*/ void CDialog3::OnBnClickedSaveimg() { // TODO: 在此添加控件通知处理程序代码 m_Image_Count++; CString sPath; sPath = ".\\image\\"; CString sTemp; sTemp.Format("Q%d", m_Image_Count); this->SetDlgItemTextA(IDC_SAVEIMG,sTemp); CTime time = CTime::GetCurrentTime(); // CString sfilename; sfilename = sPath + sTemp; #if 0 int Width = 3664; int Height= 2748; { int nImageSize = Width*Height; BYTE* BmpBuffer = (BYTE *) malloc(nImageSize * 3 + 512); //分配的空间必须足够大,请跟据你需要抓图的实际大小设置。 if (BmpBuffer != NULL) { CameraCaptureToBuf(BmpBuffer, DATA_TYPE_RGB24, R3664_2748);//R640_480 SaveBmpFile(sfilename+".bmp", BmpBuffer, Width, Height); } free(BmpBuffer); BmpBuffer = NULL; } // CameraEnableDeadPixelCorrection(); // CameraSetDisplayWindow(160,120,320,240); #else if (R_ROI == m_CaptureResolution) { CameraSetROI(m_HOff, m_VOff, m_Width, m_Height); }// CameraCaptureFile(sfilename, m_FileType, 100, m_CaptureResolution); //MessageBox(sfilename); #endif if(m_Image_Count >= 7) { this->SetDlgItemTextA(IDC_SAVEIMG,"&Save"); this->GetDlgItem(IDC_CALIBRATECAMERA)->EnableWindow(TRUE); } return; }
/*============================================================== Name: OnSavefile Desc: save the file Param: Return: Note: set the save file name and path... //the default here is exe file path... 这里可以选择存储某一时间的图片,图片格式通过setup选择 --------------------------------------------------------------*/ void CDialog3::OnBnClickedSavefile() { // TODO: 在此添加控件通知处理程序代码 // TODO: 在此添加控件通知处理程序代码 CTime time = CTime::GetCurrentTime(); CString sPath; GetModuleFileName(NULL,sPath.GetBuffer(256),256); sPath.ReleaseBuffer(256); // MessageBox(sPath); int nPos = sPath.ReverseFind('\\'); sPath = sPath.Left(nPos + 1); sPath = ".\\image\\"; CString sfilename; sfilename.Format("%sP%02d%02d%02d%02d%02d", sPath, time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond()); #if 0 int Width = 3664; int Height= 2748; { int nImageSize = Width*Height; BYTE* BmpBuffer = (BYTE *) malloc(nImageSize * 3 + 512); //分配的空间必须足够大,请跟据你需要抓图的实际大小设置。 if (BmpBuffer != NULL) { CameraCaptureToBuf(BmpBuffer, DATA_TYPE_RGB24, R3664_2748);//R640_480 SaveBmpFile(sfilename+".bmp", BmpBuffer, Width, Height); } free(BmpBuffer); BmpBuffer = NULL; } // CameraEnableDeadPixelCorrection(); // CameraSetDisplayWindow(160,120,320,240); #else if (R_ROI == m_CaptureResolution) { CameraSetROI(m_HOff, m_VOff, m_Width, m_Height); }// CameraCaptureFile(sfilename, m_FileType, 90, m_CaptureResolution); MessageBox(sfilename); #endif return ; }