//Function: Constructor //Description: Creates pointers to data structures contained by TwoPhotonGui to set up acquisition // Sets up Vision modules TwoPhotonThread::TwoPhotonThread(ScanEngine *scanEngi, AcqEngine *acqEngi, DataFile2P *data2Pi, zStepperDriver *zStepper, AomControl *aCtrl) { scanEng = scanEngi; acqEng = acqEngi; data2P = data2Pi; zStep = *zStepper; aomCtrl = aCtrl; Point toolPos; toolPos.x=850; toolPos.y=20; //temporary scaling scaleMin1 = 0; scaleMax1 = 32767; scaleMin2 = 0; scaleMax2 = 32767; //Setup diplay and display tools using NIVision calls image1 = imaqCreateImage(IMAQ_IMAGE_RGB, 0); displayWinNum1 = 1; imaqDisplayImage(image1, displayWinNum1, 1); imaqSetWindowTitle(1, "PMT Images"); imaqSetWindowSize(1, 256, 256); posWindow1.x = 850; posWindow1.y = 300; imaqMoveWindow(1, posWindow1); imaqShowToolWindow (TRUE); imaqMoveToolWindow(toolPos); imaqSetCurrentTool (IMAQ_POLYLINE_TOOL); image2 = imaqCreateImage(IMAQ_IMAGE_U8, 0); displayWinNum2 = 2; imaqDisplayImage(image2, displayWinNum2, 1); imaqSetWindowTitle(2, "ROI Images"); imaqSetWindowSize(2, 256, 256); posWindow2.x = 850; posWindow2.y = 590; imaqMoveWindow(2, posWindow2); intScalingCoeff = 1.0; bScaleCoeffCalc = false; //Allocate memory for display arrays. imageData1 = new RGBValue[acqEng->getnumValidXSamps() * acqEng->getnumValidYSamps()]; imageData2 = new unsigned char[acqEng->getWidth() * acqEng->getRepeats()]; bContinuous = false; bLifetimeFov = false; bLinescan = false; }
int CVICALLBACK Thresholding (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int threshold = 0; int histogram[256] = {0}; HistogramReport *report = NULL; switch (event) { case EVENT_COMMIT: GetCtrlVal (mypanel, MYPANEL_THRESHOLD_SLIDE, &threshold); imaqThreshold (destimage, sourimage, threshold, 255, TRUE, 255); imaqSetWindowTitle (1, "Picture after binaryzation"); imaqMoveWindow (1, imaqMakePoint (150, 260)); imaqDisplayImage (destimage, 1, TRUE); report = imaqHistogram (destimage, 256, 0, 255, IMAQ_IMAGE_U8); DeleteGraphPlot (mypanel, MYPANEL_MYGRAPH, -1, VAL_IMMEDIATE_DRAW); PlotY (mypanel, MYPANEL_MYGRAPH, (*report).histogram, 256, VAL_UNSIGNED_INTEGER, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED); break; } return 0; }
int CVICALLBACK Load_Picture (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { char picname[512] = {'\0'}; int ret = 0; HistogramReport *report = NULL; switch (event) { case EVENT_COMMIT: ret = FileSelectPopup ("", "*.*", "", "Load; select an image file", VAL_LOAD_BUTTON, 0, 0, 1, 0, picname); if (ret == 1) { imaqReadFile (sourimage, picname, NULL, NULL); imaqMoveWindow (0, imaqMakePoint (50, 260)); imaqDisplayImage (sourimage, 0, TRUE); report = imaqHistogram (sourimage, 256, 0, 255, IMAQ_IMAGE_U8); DeleteGraphPlot (mypanel, MYPANEL_MYGRAPH, -1, VAL_IMMEDIATE_DRAW); PlotY (mypanel, MYPANEL_MYGRAPH, (*report).histogram, 256, VAL_UNSIGNED_INTEGER, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED); } break; } return 0; }
int sgl_grab(CameraSgl *camera) { ImageInfo info; IMAQdxError error = 0; CameraData *data = &camera->data; int left = camera->rect_show.left; int top = camera->rect_show.top; if (sgl_is_opend(camera)) { error = IMAQdxGrab (camera->session_id, data->image, TRUE, &data->buffer_num); if (error) { goto ERROR_MSG; } if (camera->attached_win != NULL) { if (camera->visible) { imaqDisplayImage (camera->data.image, camera->display_win_num, FALSE); if (error) { goto ERROR_MSG; } // 获取额外的信息 imaqGetImageInfo (data->image, &info); imaqMoveWindow ( camera->display_win_num, MakePoint( left, top) ); imaqShowWindow (camera->display_win_num, TRUE); // printf("grab ---- visible\n"); } else { imaqShowWindow (camera->display_win_num, FALSE); // printf("grab ---- invisible\n"); } } } return 0; ERROR_MSG: sgl_camera_message_error(error, camera->error_callback); return -1; }