void QProcessResultThread::ProcessPlateResultEvent( QProcessResultEvent* pEvent ) { //if ( !pDatabaseThread->DatabasePing( ) ) { // return; //} QStringList lstParams; const QString strPlate = pEvent->GetPlate( ); const QString strDateTime = pEvent->GetDateTime( ); QString strIP = pEvent->GetIP( ); int nChannel = pEvent->GetImageChannel( ); bool bEnter = pEvent->GetEnterFlag( ); if ( SamePlateInInterval( bEnter, strPlate, strDateTime ) ) { return; } QString strFile; if ( pEvent->GetIpcCamera( ) ) { CaptureImage( strFile, strPlate, strIP ); } else { CaptureImage( strFile, strPlate, nChannel ); } QByteArray byFileData; QCommonFunction::ReadAllFile( strFile, byFileData ); if ( bDeleteImage && QFile::exists( strFile ) ) { QFile::remove( strFile ); } QString strImageBase64; QCommonFunction::GetImageBase64( strImageBase64, byFileData ); QUuid uuid = QUuid::createUuid( ); QString strUUID = uuid.toString( ); lstParams << ( bEnter ? "1" : "0" ) << strPlate << strDateTime << strImageBase64 << strUUID << QString::number( nChannel ); //qDebug ( ) << ( bEnter ? "1" : "0" ) << strPlate << endl; static int nConnectID = 1; //QDbPoolNewTask* pTask = QDbPoolNewTask::CreateTask( ParkSolution::SpWriteInOutRecord, lstParams, this, nConnectID++ ); //pThreadPool->start( pTask ); pDatabaseThread->PostWriteInOutRecordEvent( lstParams, nConnectID ); if ( nConnectPoolCount == nConnectID++ ) { nConnectID = 1; } //pSerializeThread->PostSetPlateDataEvent( strUUID, strPlate, strDateTime, byFileData ); }
void InterruptHandler(int sig) { int phase=2; fprintf(stdout,"Integration terminated by user.\n"); for (int cam_num = 0; cam_num <ccd_ncam; cam_num++) { CaptureImage(&phase,ccd_image_data[cam_num],ccd_type,0,FALSE,0,0,0,0); SBIGUnivDrvCommand(CC_CLOSE_DEVICE, NULL, NULL); SBIGUnivDrvCommand(CC_CLOSE_DRIVER, NULL, NULL); } release_lock(); exit(EXIT_FAILURE); }
void CDataParser::CreateInfraredReponse( QByteArray& byResponse, quint8 nState, quint8 nAddress ) { quint32 nTcpStreamLength = Protocol::nHeadLength + sizeof ( quint8 ) * 2; nTcpStreamLength = htonl( nTcpStreamLength ); byResponse.append( ( const char* ) &nTcpStreamLength, sizeof ( quint32 ) ); byResponse.append( nAddress ); // 1 / 2 byResponse.append( nState ); if ( nState ) { CaptureImage( nAddress - 1 ); } }
void ScreenCapturerMagnifier::Capture(RECT srcRect) { if (m_bMagInitialized) { bool result = CaptureImage(srcRect); if (result) { m_Callback->OnCaptureComplete(m_pData, &m_bmif); return; } } m_Callback->OnCaptureComplete(nullptr, nullptr); }
// ************************************************************************* // ************** Main For Testing *************************************** // ************************************************************************* // This main tests See3CAM_CU40 which is RGB-IR camera which only outputs // Y16 formatted data of its Bayer pixels. It provides 10 bit data. // This format is nearly impossible to support using standard streams. int main(int argc, char* argv[]) { int width = 672; int height = 380; if (argc > 1) { char* argstring0 = argv[0]; char* argstring1 = argv[1]; sscanf(argv[1], "%dx%d", &width, &height); } CameraV4L2 cam("/dev/video0",512); if(!cam.Exists()) { fprintf(stderr, "Unable to Open Camera"); return 0; } if (cam.SetSize(width, height)) { fprintf(stderr, "Requested Size %dx%d is not supported",width,height); exit -1; } if(cam.PrintCaps()) // also sets up m_fmt return 1; if(cam.RequestBuffers(1)) return 1; cv::Mat frameRGB; cv::Mat frameIR; if (RGB16) { frameRGB.create(height, width, CV_16UC3); frameIR.create(height, width, CV_16UC1); } else { frameRGB.create(height, width, CV_8UC3); frameIR.create(height, width, CV_8UC1); } if(CaptureImage(&cam, frameRGB, frameIR)) return 1; printf ("saving images\n"); cv::imwrite("/home/frank/Pictures/RGB.png",frameRGB); cv::imwrite("/home/frank/Pictures/IR.png",frameIR); return 0; }
void QDigitalCameraThread::SendCaptureImage( QString& strFile, QString& strIP ) { emit CaptureImage( strFile, strIP ); }
void QAnalogCameraThread::SendCaptureImage( QString& strFile, int nChannel ) { emit CaptureImage( strFile, nChannel ); }
int main(int argc, char *argv[]) { int arg=1; int sbig_type = NO_CAMERA; int info_mode = 0; int verbose = 0; char name[MAX_STRING] = ""; char ra[MAX_STRING] = ""; char dec[MAX_STRING] = ""; char alt[MAX_STRING] = ""; char az[MAX_STRING] = ""; char imtype[8]; int phase; float exptime; int err; /* Set an interrupt handler to trap Ctr-C nicely */ if(signal(SIGINT, SIG_IGN) != SIG_IGN) signal(SIGINT, InterruptHandler); /* set lockfile from the outset */ get_lock(); store_pid_in_lockfile(); /* parse args */ if (argc < 3) { error_exit(usage); }; while (arg < argc - 2) { switch (argv[arg++][1]) { case 'v': verbose = 1; SetVerbosity(verbose); break; case 'n': sscanf(argv[arg++], "%s", name); break; case 'r': sscanf(argv[arg++], "%s", ra); break; case 'd': sscanf(argv[arg++], "%s", dec); break; case 'a': sscanf(argv[arg++], "%s", alt); break; case 'z': sscanf(argv[arg++], "%s", az); break; default: error_exit(usage); break; } } sscanf(argv[arg++],"%s",imtype); sscanf(argv[arg++],"%f",&exptime); // Determine what kind of image to take switch(value_from_imagetype_key(imtype)) { case DARK: ccd_type=DARK; if (verbose) printf("Taking dark frame.\n"); break; case LIGHT: ccd_type=LIGHT; if (verbose) printf("Taking light frame.\n"); break; case BIAS: ccd_type=BIAS; if (verbose) printf("Taking bias frame.\n"); break; case FLAT: ccd_type=FLAT; if (verbose) printf("Taking flat frame.\n"); break; case BADKEY: fprintf(stderr,"Unknown image type %s\n",imtype); return(1); break; } fflush(stdout); CountCameras(); if (ccd_ncam < 1){ fprintf(stderr,"Found 0 cameras\n"); return(1); } InitializeAllCameras(); store_timestamped_note_in_lockfile("Started"); store_directory_in_lockfile(); char myline[128]; sprintf(myline,"Exptime: %5.1f\n",exptime); store_note_in_lockfile(myline); // Start integrations going on each of the cameras one by one. for (int cam_num = 0; cam_num <ccd_ncam; cam_num++) { err = SetActiveCamera(cam_num); ccd_image_data[cam_num] = (unsigned short *) malloc(ccd_image_width*ccd_image_height*sizeof(unsigned short)); phase = 0; err = CaptureImage(&phase,ccd_image_data[cam_num],ccd_type,exptime,FALSE,0,0,0,0); } // Wait until the data is ready. I'm intentionally playing this safe by // making sure I wait at least 1s before trying to read out the data. // This is something I will have to look into if I ever use this for // fast focusing. int nsec = (int) exptime + 1; int count = 0; for (int i=0; i<=nsec;i++) { if(nsec > 3 && nsec < 10){ load_bar(count++,nsec,3,30); } else if (nsec > 10 && nsec < 100){ load_bar(count++,nsec,(int)(nsec/2),30); } else if (nsec > 100){ load_bar(count++,nsec,(int)(nsec/3),30); } sleep(1); } // The cameras are ready to be read out. We once again cycle over each camera and // save the data. for (int cam_num = 0; cam_num <ccd_ncam; cam_num++) { char infoline[128]; phase = 1; err = SetActiveCamera(cam_num); fflush(stderr); err = CaptureImage(&phase,ccd_image_data[cam_num],ccd_type,exptime,FALSE,0,0,0,0); // Print out some pixel values to let the user check data integrity if (verbose) printf("Some pixel values: %u %u %d\n", *(ccd_image_data[cam_num] + 10000), *(ccd_image_data[cam_num] + 15000), *(ccd_image_data[cam_num]+20000)); // Figure out what to call the new file char *newname; newname = (char *)malloc(MAX_STRING*sizeof(char)); new_filename(ccd_serial_number,imtype,newname); // Save as a FITS file GetCameraTemperature(); double temperature = ccd_camera_info[ActiveCamera()].temperature; int filterNumber = 0; if (IsCameraAnST402ME()) filterNumber = FilterWheelPosition(); write_fits(newname, ccd_image_width, ccd_image_height, ccd_image_data[cam_num], exptime,imtype,temperature,filterNumber,ccd_serial_number, name, ra,dec,alt,az); fprintf(stderr,"Saved %s \n",newname); sprintf(infoline,"Camera %d wrote: %s\n",cam_num,newname); store_note_in_lockfile(infoline); free(ccd_image_data[cam_num]); free(newname); } DisconnectAllCameras(); release_lock(); store_timestamped_note_in_lockfile("Completed"); // Release the lock file release_lock(); // Ring bell to wake up the astronomer if (verbose) printf("Camera(s) opened and closed successfully.\n"); putchar('\a'); putchar('\a'); putchar('\a'); return(0); }