当前位置: 首页>>代码示例>>C++>>正文


C++ Flag::raise方法代码示例

本文整理汇总了C++中Flag::raise方法的典型用法代码示例。如果您正苦于以下问题:C++ Flag::raise方法的具体用法?C++ Flag::raise怎么用?C++ Flag::raise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Flag的用法示例。


在下文中一共展示了Flag::raise方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Stream

void ImperxStream::Stream(unsigned char *frame, Semaphore &frame_semaphore, Flag &stream_flag)
{
    // The pipeline is already "armed", we just have to tell the device
    // to start sending us images
    printf( "Sending StartAcquisition command to device\n" );
    lDeviceParams->ExecuteCommand( "AcquisitionStart" );

    char lDoodle[] = "|\\-|-/";
    int lDoodleIndex = 0;
    PvInt64 lImageCountVal = 0;
    double lFrameRateVal = 0.0;
    double lBandwidthVal = 0.0;

    // Acquire images until the user instructs us to stop
    printf( "\n<press a key to stop streaming>\n" );
    while ( stream_flag.check() )
    {
	std::cout << "here\n";
	// Retrieve next buffer		
	PvBuffer *lBuffer = NULL;
	PvResult  lOperationResult;
	PvResult lResult = lPipeline.RetrieveNextBuffer( &lBuffer, 1000, &lOperationResult );
        
	if ( lResult.IsOK() )
        {
	    if ( lOperationResult.IsOK() )
            {
		// Process Buffer
		lStreamParams->GetIntegerValue( "ImagesCount", lImageCountVal );
		lStreamParams->GetFloatValue( "AcquisitionRateAverage", lFrameRateVal );
		lStreamParams->GetFloatValue( "BandwidthAverage", lBandwidthVal );
            
		// If the buffer contains an image, display width and height
		PvUInt32 lWidth = 0, lHeight = 0;
		if ( lBuffer->GetPayloadType() == PvPayloadTypeImage )
		{
		    // Get image specific buffer interface
		    PvImage *lImage = lBuffer->GetImage();

		    // Read width, height
		    lWidth = lBuffer->GetImage()->GetWidth();
		    lHeight = lBuffer->GetImage()->GetHeight();
		    stream_flag.raise();	    

		}

		std::cout << lWidth << " " << lHeight << "\n";
	    
            }
	    // We have an image - do some processing (...) and VERY IMPORTANT,
	    // release the buffer back to the pipeline
	    //semaphore thing
	    //get all in there.
	    //a semaphore thing
    	
	    lPipeline.ReleaseBuffer( lBuffer );
        }
	else
        {
	    // Timeout
	    printf( "%c Timeout\r", lDoodle[ lDoodleIndex ] );
        }

	++lDoodleIndex %= 6;

    }
}
开发者ID:cello623,项目名称:SAS,代码行数:67,代码来源:ImperxStream.cpp

示例2: if

void *CameraStreamThread( void * threadargs)
{    
    long tid = (long)((struct Thread_data *)threadargs)->thread_id;
    printf("CameraStream thread #%ld!\n", tid);

    ImperxStream camera;

    cv::Mat localFrame;
    timespec preExposure, postExposure, timeElapsed, duration;
    int width, height;
    int failcount = 0;

    uint16_t localExposure = exposure;
    int16_t localPreampGain = preampGain;
    uint16_t localAnalogGain = analogGain;

    cameraReady = 0;
    staleFrame = true;
    while(1)
    {
        if (stop_message[tid] == 1)
        {
            printf("CameraStream thread #%ld exiting\n", tid);
            camera.Stop();
            camera.Disconnect();
            started[tid] = false;
            pthread_exit( NULL );
        }
        else if (cameraReady == false)
        {
            if (camera.Connect() != 0)
            {
                std::cout << "Error connecting to camera!\n";
                sleep(SLEEP_CAMERA_CONNECT);
                continue;
            }
            else
            {
                camera.ConfigureSnap();
                camera.SetROISize(CAMERA_XSIZE,CAMERA_YSIZE);
                camera.SetROIOffset(CAMERA_XOFFSET,CAMERA_YOFFSET);
                camera.SetExposure(localExposure);
                camera.SetAnalogGain(localAnalogGain);
                camera.SetPreAmpGain(localPreampGain);

                width = camera.GetROIWidth();
                height = camera.GetROIHeight();
                localFrame.create(height, width, CV_8UC1);
                if(camera.Initialize() != 0)
                {
                    std::cout << "Error initializing camera!\n";
                    //may need disconnect here
                    sleep(SLEEP_CAMERA_CONNECT);
                    continue;
                }
                cameraReady = 1;
                frameCount = 0;
            }
        }
        else
        {
            if (localExposure != exposure) {
                localExposure = exposure;
                camera.SetExposure(localExposure);
            }
            
            if (localPreampGain != preampGain) {
                localPreampGain = preampGain;
                camera.SetPreAmpGain(localPreampGain);
            }
            
            if (localAnalogGain != analogGain) {
                localAnalogGain = analogGain;
                camera.SetAnalogGain(analogGain);
            }

            clock_gettime(CLOCK_REALTIME, &preExposure);

            if(!camera.Snap(localFrame))
            {
                failcount = 0;
                procReady.raise();
                saveReady.raise();

                //printf("CameraStreamThread: trying to lock\n");
                pthread_mutex_lock(&mutexImage);
                //printf("CameraStreamThread: got lock, copying over\n");
                localFrame.copyTo(frame);
                frameTime = preExposure;
                //printf("%d\n", frame.at<uint8_t>(0,0));
                frameCount++;
                pthread_mutex_unlock(&mutexImage);
                staleFrame = false;

                //printf("camera temp is %lld\n", camera.getTemperature());
                camera_temperature = camera.getTemperature();
            }
            else
            {
                failcount++;
//.........这里部分代码省略.........
开发者ID:kjgregory,项目名称:SAS,代码行数:101,代码来源:sunDemo.cpp


注:本文中的Flag::raise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。