// stop streaming void CameraStop() { tPvErr errCode; //stop camera receiving triggers if ((errCode = PvCommandRun(GCamera.Handle,"AcquisitionStop")) != ePvErrSuccess) printf("AcquisitionStop command err: %u\n", errCode); else printf("AcquisitionStop success.\n"); //PvCaptureQueueClear aborts any actively written frame with Frame.Status = ePvErrDataMissing //Further queued frames returned with Frame.Status = ePvErrCancelled //Add delay between AcquisitionStop and PvCaptureQueueClear //to give actively written frame time to complete Sleep(200); printf("Calling PvCaptureQueueClear...\n"); if ((errCode = PvCaptureQueueClear(GCamera.Handle)) != ePvErrSuccess) printf("PvCaptureQueueClear err: %u\n", errCode); else printf("...Queue cleared.\n"); //stop driver stream if ((errCode = PvCaptureEnd(GCamera.Handle)) != ePvErrSuccess) printf("PvCaptureEnd err: %u\n", errCode); else printf("Driver stream stopped.\n"); }
void Camera::start(FrameStartTriggerMode fmode, AcquisitionMode amode) { //assert( FSTmode_ == None && fmode != None ); ///@todo verify this assert again //assert( fmode == SyncIn1 || fmode == SyncIn2 || fmode == Software || !userCallback_.empty() ); // set camera in acquisition mode CHECK_ERR( PvCaptureStart(handle_), "Could not start capture"); if (fmode == Freerun || fmode == SyncIn1 || fmode == SyncIn2 || fmode == FixedRate) for (unsigned int i = 0; i < bufferSize_; ++i) PvCaptureQueueFrame(handle_, frames_ + i, Camera::frameDone); // start capture after setting acquisition and trigger modes try { ///@todo take this one also as an argument CHECK_ERR( PvAttrEnumSet(handle_, "AcquisitionMode", acquisitionModes[amode]), "Could not set acquisition mode" ); CHECK_ERR( PvAttrEnumSet(handle_, "FrameStartTriggerMode", triggerModes[fmode]), "Could not set trigger mode" ); CHECK_ERR( PvCommandRun(handle_, "AcquisitionStart"), "Could not start acquisition" ); } catch (ProsilicaException& e) { PvCaptureEnd(handle_); // reset to non capture mode throw; // rethrow } FSTmode_ = fmode; Amode_ = amode; }
void CvCaptureCAM_PvAPI::close() { // Stop the acquisition & free the camera PvCommandRun(Camera.Handle, "AcquisitionStop"); PvCaptureEnd(Camera.Handle); PvCameraClose(Camera.Handle); }
//-------------------------------------------------------------------- void ofxVideoGrabberPvAPI::close(){ if( bGrabberInited ) { // stop the streaming PvCommandRun(cameraHandle,"AcquisitionStop"); PvCaptureEnd(cameraHandle); // unsetup the camera PvCameraClose(cameraHandle); // and free the image buffer of the frame delete [] (char*)cameraFrame.ImageBuffer; } if( bPvApiInitiated ) { // uninitialise the API PvUnInitialize(); } if (pixels != NULL){ delete[] pixels; pixels = NULL; } tex.clear(); }
// setup and start streaming // return value: true == success, false == fail bool CameraStart() { tPvErr errCode; // NOTE: This call sets camera PacketSize to largest sized test packet, up to 8228, that doesn't fail // on network card. Some MS VISTA network card drivers become unresponsive if test packet fails. // Use PvUint32Set(handle, "PacketSize", MaxAllowablePacketSize) instead. See network card properties // for max allowable PacketSize/MTU/JumboFrameSize. if((errCode = PvCaptureAdjustPacketSize(GCamera.Handle,8228)) != ePvErrSuccess) { printf("CameraStart: PvCaptureAdjustPacketSize err: %u\n", errCode); return false; } // start driver capture stream if((errCode = PvCaptureStart(GCamera.Handle)) != ePvErrSuccess) { printf("CameraStart: PvCaptureStart err: %u\n", errCode); return false; } // queue frame if((errCode = PvCaptureQueueFrame(GCamera.Handle,&(GCamera.Frame),NULL)) != ePvErrSuccess) { printf("CameraStart: PvCaptureQueueFrame err: %u\n", errCode); // stop driver capture stream PvCaptureEnd(GCamera.Handle); return false; } // set the camera in hardware trigger, continuous mode, and start camera receiving triggers if((PvAttrEnumSet(GCamera.Handle,"FrameStartTriggerMode","SyncIn1") != ePvErrSuccess) || (PvAttrEnumSet(GCamera.Handle,"AcquisitionMode","Continuous") != ePvErrSuccess) || (PvCommandRun(GCamera.Handle,"AcquisitionStart") != ePvErrSuccess)) { printf("CameraStart: failed to set camera attributes\n"); // clear queued frame PvCaptureQueueClear(GCamera.Handle); // stop driver capture stream PvCaptureEnd(GCamera.Handle); return false; } return true; }
// setup and start streaming void cameraStart(tCamera* camera, tPvUint32 packetSize) { cameraSetPixelFormat(camera, "Mono16"); cameraSetExpo(camera, 1000); //tPvUint32 ROI[4]={0,0,493,659}; //cameraSetROI(camera,ROI); // Auto adjust the packet size to max supported by the network, up to a max of 8228. // NOTE: In Vista, if the packet size on the network card is set lower than 8228, // this call may break the network card's driver. See release notes. // tPvErr err = PvCaptureAdjustPacketSize(camera->Handle,packetSize); //err = PvAttrUint32Set(camera->Handle, "PacketSize", 1500); if (err != ePvErrSuccess){ stringstream buf; buf << "failed to adjust packet size : " << cameraGetError(err) << endl; throw buf.str(); } unsigned long FrameSize = 0; err = PvAttrUint32Get(camera->Handle, "TotalBytesPerFrame", &FrameSize); if (err != ePvErrSuccess){ stringstream buf; buf << "failed to get TotalBytesPerFrame : " << cameraGetError(err) << endl; throw buf.str(); } // allocate the buffer for the single frame we need camera->Frame.Context[0] = camera; camera->Frame.ImageBuffer = new char[FrameSize]; if (camera->Frame.ImageBuffer) camera->Frame.ImageBufferSize = FrameSize; else throw "failed allocate Frame.ImageBuffer"; // how big should the frame buffers be? if (!err) { // set the camera is capture mode if (!PvCaptureStart(camera->Handle)) { // set the camera in continuous acquisition mode if (!PvAttrEnumSet(camera->Handle, "FrameStartTriggerMode", "Freerun")) { //"FixedRate" / "Freerun" // and set the acquisition mode into continuous if (PvCommandRun(camera->Handle, "AcquisitionStart")) { // if that fail, we reset the camera to non capture mode PvCaptureEnd(camera->Handle); throw "failed to set the acquisition mode into continuous"; } } else throw "failed to set the camera in continuous acquisition mode"; } else throw "failed to set the camera is capture mode"; } else throw "failed to get TotalBytesPerFrame parameter"; }
void Camera::stop() { if (FSTmode_ == None) return; PvCommandRun(handle_, "AcquisitionStop"); PvCaptureEnd(handle_); PvCaptureQueueClear(handle_); FSTmode_ = None; }
void OmniCamera::stop(void) { if(isConnected()) { PvCommandRun(_camera.handle,"AcquisitionStop"); PvCaptureEnd(_camera.handle); PvCameraClose(_camera.handle); if(_camera.frame.ImageBuffer) delete [] (char*)_camera.frame.ImageBuffer; _camera.handle = NULL; _connected = false; } }
// setup and start streaming bool CameraStart(tCamera* Camera) { unsigned long FrameSize = 0; // Auto adjust the packet size to max supported by the network, up to a max of 8228. // NOTE: In Vista, if the packet size on the network card is set lower than 8228, // this call may break the network card's driver. See release notes. // //PvCaptureAdjustPacketSize(Camera->Handle,8228); // how big should the frame buffers be? if(!PvAttrUint32Get(Camera->Handle,"TotalBytesPerFrame",&FrameSize)) { bool failed = false; // allocate the buffer for the single frame we need Camera->Frame.Context[0] = Camera; Camera->Frame.ImageBuffer = new char[FrameSize]; if(Camera->Frame.ImageBuffer) Camera->Frame.ImageBufferSize = FrameSize; else failed = true; if(!failed) { // set the camera is capture mode if(!PvCaptureStart(Camera->Handle)) { // set the camera in continuous acquisition mode if(!PvAttrEnumSet(Camera->Handle,"FrameStartTriggerMode","Freerun")) { // and set the acquisition mode into continuous if(PvCommandRun(Camera->Handle,"AcquisitionStart")) { // if that fail, we reset the camera to non capture mode PvCaptureEnd(Camera->Handle) ; return false; } else return true; } else return false; } else return false; } else return false; } else return false; }
bool CameraGigE::onStart() { // set the camera is acquisition mode if (!PvCaptureStart(cHandle)) { // start the acquisition and make sure the trigger mode is "freerun" if (PvCommandRun(cHandle, "AcquisitionStart")) { // if that fail, we reset the camera to non capture mode PvCaptureEnd(cHandle); return false; } else return true; } else return false; }
// // idlPvCaptureEnd // // Shut down the image capture stream. // // command line arguments // argv[0]: IN/FLAG debug // argv[1]: IN camera index int idlPvCaptureEnd (int argc, char *argv[]) { unsigned long n; unsigned long err; debug = *(IDL_INT *) argv[0]; n = *(unsigned long *) argv[1]; CHECKINDEX(n); err = PvCaptureEnd(camera[n]); return idlPvErrCode(err); }
// setup and start streaming bool CameraStart(tCamera* Camera) { unsigned long FrameSize = 0; // how big should the frame buffers be? if(!PvAttrUint32Get(Camera->Handle,"TotalBytesPerFrame",&FrameSize)) { bool failed = false; // allocate the buffer for the single frame we need Camera->Frame.Context[0] = Camera; Camera->Frame.ImageBuffer = new char[FrameSize]; if(Camera->Frame.ImageBuffer) Camera->Frame.ImageBufferSize = FrameSize; else failed = true; if(!failed) { // set the camera is capture mode if(!PvCaptureStart(Camera->Handle)) { // set the camera in continuous acquisition mode if(!PvAttrEnumSet(Camera->Handle,"FrameStartTriggerMode","Freerun")) { // and set the acquisition mode into continuous if(PvCommandRun(Camera->Handle,"AcquisitionStart")) { // if that fail, we reset the camera to non capture mode PvCaptureEnd(Camera->Handle) ; return false; } else return true; } else return false; } else return false; } else return false; } else return false; }
// setup and start streaming bool CameraStart() { unsigned long FrameSize = 0; // how big should the frame buffers be? if(!PvAttrUint32Get(GCamera.Handle,"TotalBytesPerFrame",&FrameSize)) { bool failed = false; // allocate the buffer for the single frame we need GCamera.Frame.ImageBuffer = new char[FrameSize]; if(GCamera.Frame.ImageBuffer) GCamera.Frame.ImageBufferSize = FrameSize; else failed = true; if(!failed) { // set the camera is capture mode if(!PvCaptureStart(GCamera.Handle)) { // and set the acquisition mode into continuous and software trigger mode if(PvAttrEnumSet(GCamera.Handle,"FrameStartTriggerMode","SyncIn1") || PvCommandRun(GCamera.Handle,"AcquisitionStart")) { // if that fail, we reset the camera to non capture mode PvCaptureEnd(GCamera.Handle) ; return false; } else return true; } else return false; } else return false; } else return false; }
// stop streaming void CameraStop() { tPvErr errCode; //stop camera receiving triggers if ((errCode = PvCommandRun(GCamera.Handle,"AcquisitionStop")) != ePvErrSuccess) printf("AcquisitionStop command err: %u\n", errCode); else printf("Camera stopped.\n"); //clear queued frames. will block until all frames dequeued if ((errCode = PvCaptureQueueClear(GCamera.Handle)) != ePvErrSuccess) printf("PvCaptureQueueClear err: %u\n", errCode); else printf("Queue cleared.\n"); //stop driver stream if ((errCode = PvCaptureEnd(GCamera.Handle)) != ePvErrSuccess) printf("PvCaptureEnd err: %u\n", errCode); else printf("Driver stream stopped.\n"); }
// stop streaming void CameraStop() { PvCommandRun(GCamera.Handle,"AcquisitionStop"); PvCaptureEnd(GCamera.Handle); }
void CvCaptureCAM_PvAPI::stopCapture() { PvCommandRun(Camera.Handle, "AcquisitionStop"); PvCaptureEnd(Camera.Handle); }
bool CameraGigE::onStop() { PvCommandRun(cHandle, "AcquisitionStop"); PvCaptureEnd(cHandle); return true; }
// stop streaming void CameraStop(tCamera* Camera) { PvCommandRun(Camera->Handle,"AcquisitionStop"); PvCaptureEnd(Camera->Handle); }
// stop streaming void cameraStop(tCamera* camera) { PvCommandRun(camera->Handle, "AcquisitionStop"); PvCaptureEnd(camera->Handle); // and free the image buffer of the frame delete[] (char*) camera->Frame.ImageBuffer; }
//-------------------------------------------------------------------- bool ofxVideoGrabberPvAPI::initGrabber(int w, int h, bool setUseTexture){ width = w; height = h; tPvErr ret; //PvAPI return codes bUseTexture = setUseTexture; memset( &cameraUID, 0, sizeof(cameraUID) ); memset( &cameraHandle, 0, sizeof(cameraHandle) ); memset( &cameraFrame, 0, sizeof(cameraFrame) ); //---------------------------------- 1 - open the sequence grabber // lazy initialization of the Prosilica API if( !bPvApiInitiated ){ ret = PvInitialize(); if( ret == ePvErrSuccess ) { ofLog(OF_LOG_VERBOSE, "PvAPI initialized"); } else { ofLog(OF_LOG_ERROR, "unable to initialize PvAPI"); return false; } bPvApiInitiated = true; } //---------------------------------- 3 - buffer allocation // Create a buffer big enough to hold the video data, // make sure the pointer is 32-byte aligned. // also the rgb image that people will grab pixels = new unsigned char[width*height]; // check for any cameras plugged in int waitIterations = 0; while( PvCameraCount() < 1 ) { ofSleepMillis(250); waitIterations++; if( waitIterations > 8 ) { ofLog(OF_LOG_ERROR, "error: no camera found"); return false; } } //---------------------------------- 4 - device selection tPvUint32 count, connected; tPvCameraInfo list[maxConcurrentCams]; count = PvCameraList( list, maxConcurrentCams, &connected ); if(count >= 1) { bool bSelectedDevicePresent = false; if(bChooseDevice) { //check if selected device is available for( int i=0; i<count; ++i) { if( deviceID == list[i].UniqueId ) { bSelectedDevicePresent = true; cameraUID = list[i].UniqueId; } } } if( !bSelectedDevicePresent ){ cameraUID = list[0].UniqueId; ofLog(OF_LOG_NOTICE, "cannot find selected camera -> defaulting to first available"); ofLog(OF_LOG_VERBOSE, "there is currently an arbitrary hard limit of %i concurrent cams", maxConcurrentCams); } } else { ofLog(OF_LOG_ERROR, "no cameras available"); return false; } //---------------------------------- 5 - final initialization steps ret = PvCameraOpen( cameraUID, ePvAccessMaster, &cameraHandle ); if( ret == ePvErrSuccess ){ ofLog(OF_LOG_VERBOSE, "camera opened"); } else { if( ret == ePvErrAccessDenied ) { ofLog(OF_LOG_ERROR, "camera access denied, probably already in use"); } ofLog(OF_LOG_ERROR, "failed to open camera"); return false; } unsigned long FrameSize = 0; ret = PvAttrUint32Get( cameraHandle, "TotalBytesPerFrame", &FrameSize ); if( ret == ePvErrSuccess ){ // allocate the buffer for the single frame we need cameraFrame.ImageBuffer = new char[FrameSize]; cameraFrame.ImageBufferSize = FrameSize; ofLog(OF_LOG_VERBOSE, "camera asked for TotalBytesPerFrame"); } else { ofLog(OF_LOG_ERROR, "failed to allocate capture buffer"); return false; } ret = PvCaptureStart(cameraHandle); if( ret == ePvErrSuccess ){ ofLog(OF_LOG_VERBOSE, "camera set to capture mode"); } else { if( ret == ePvErrUnplugged ){ ofLog(OF_LOG_ERROR, "cannot start capture, camera was unplugged"); } ofLog(OF_LOG_ERROR, "cannot set to capture mode"); return false; } ret = PvAttrEnumSet(cameraHandle,"FrameStartTriggerMode","Freerun"); if( ret == ePvErrSuccess ){ ofLog(OF_LOG_VERBOSE, "camera set to continuous mode"); } else { ofLog(OF_LOG_ERROR, "cannot set to continous mode"); return false; } ret = PvCommandRun(cameraHandle,"AcquisitionStart"); if( ret == ePvErrSuccess ){ ofLog(OF_LOG_VERBOSE, "camera continuous acquisition started"); } else { // if that fail, we reset the camera to non capture mode PvCaptureEnd(cameraHandle) ; ofLog(OF_LOG_ERROR, "cannot start continuous acquisition"); return false; } bGrabberInited = true; //loadSettings(); ofLog(OF_LOG_NOTICE,"camera is ready now"); //---------------------------------- 6 - setup texture if needed if (bUseTexture){ // create the texture, set the pixels to black and // upload them to the texture (so at least we see nothing black the callback) tex.allocate(width,height,GL_LUMINANCE); memset(pixels, 0, width*height); tex.loadData(pixels, width, height, GL_LUMINANCE); } // we are done return true; }