コード例 #1
0
 bool open(int _index)
 {
     // Enumerate libusb devices
     std::vector<ps3eye::PS3EYECam::PS3EYERef> devices = ps3eye::PS3EYECam::getDevices();
     std::cout << "ps3eye::PS3EYECam::getDevices() found " << devices.size() << " devices." << std::endl;
     
     if (devices.size() > (unsigned int)_index) {
         
         eye = devices[_index];
         
         if (eye && eye->init(640, 480, 60))
         {
             // Change any default settings here
             
             eye->start();
             
             eye->setAutogain(false);
             eye->setAutoWhiteBalance(false);
             
             m_index = _index;
             refreshDimensions();
             
             return true;
         }
     }
     return false;
 }
コード例 #2
0
ファイル: CCWidgetBase.cpp プロジェクト: Orange-OpenSource/2c
void CCWidgetBase::setPosition(const float x, const float y)
{
	position.x = x;
	position.y = y;
	positionTarget = position;
	refreshDimensions();
}
コード例 #3
0
 bool setProperty(int property_id, double value)
 {
     int val;
     if (!eye)
     {
         return false;
     }
     switch (property_id)
     {
     case CV_CAP_PROP_BRIGHTNESS:
         // [0, 255] [20]
         eye->setBrightness((int)round(value));
     case CV_CAP_PROP_CONTRAST:
         // [0, 255] [37]
         eye->setContrast((int)round(value));
     case CV_CAP_PROP_EXPOSURE:
         // [0, 255] [120]
         eye->setExposure((int)round(value));
     case CV_CAP_PROP_FPS:
         return false; //TODO: Modifying FPS probably requires resetting the camera
     case CV_CAP_PROP_FRAME_HEIGHT:
         return false; //TODO: Modifying frame size probably requires resetting the camera
     case CV_CAP_PROP_FRAME_WIDTH:
         return false;
     case CV_CAP_PROP_GAIN:
         // [0, 255] -> [0, 63] [20]
         val = (int)(value * 64.0 / 256.0);
         eye->setGain(val);
     case CV_CAP_PROP_HUE:
         // [0, 255] [143]
         eye->setHue((int)round(value));
     case CV_CAP_PROP_SHARPNESS:
         // [0, 255] -> [0, 63] [0]
         val = (int)(value * 64.0 / 256.0);
         eye->setSharpness((int)round(value));
     }
     
     refreshDimensions();
     
     return true;
 }
コード例 #4
0
ファイル: CCWidgetBase.cpp プロジェクト: Orange-OpenSource/2c
const bool CCWidgetBase::update(const CCTime &time)
{	
	if( enabled )
	{
		const bool positionInterpolation = position.x != positionTarget.x || position.y != positionTarget.y;
		const bool sizeInterpolation = size.width != sizeTarget.width || size.height != sizeTarget.height;
		const bool colourInterpolation = colour != NULL && colourTarget != NULL && colour->equals( *colourTarget ) == false;
		if( positionInterpolation || sizeInterpolation || colourInterpolation )
		{
			if( positionInterpolation || sizeInterpolation )
			{
				if( positionInterpolation )
				{
                    const float deltaSpeed = time.delta * movementSpeed;
                    CCToTarget( position.x, positionTarget.x, deltaSpeed );
                    CCToTarget( position.y, positionTarget.y, deltaSpeed );
				}
		
				if( sizeInterpolation )
				{
                    const float deltaSpeed = time.delta * resizeSpeed;
                    CCToTarget( size.width, sizeTarget.width, deltaSpeed );
                    CCToTarget( size.height, sizeTarget.height, deltaSpeed );
				}
				
				refreshDimensions();
			}
			
			if( colourInterpolation )
			{
                colour->toTarget( *colourTarget, time.delta * colourSpeed );
			}
			
			if( interpolating() == false )
			{
				if( onInterpolated.routine != NULL )
				{
					onInterpolated.routine( onInterpolated.parameter1, onInterpolated.parameter2 );
				}
			}
		}
		
		if( inView && distortEffect )
		{
            const float deltaSpeed = time.delta * distortSpeed;
            if( CCToTarget( distort.x, distortTarget.x, deltaSpeed ) == false )
			{
				int random = rand();
				distortTarget.x = ( random % 10 ) * distortAmount * size.width;
			}
			
            if( CCToTarget( distort.y, distortTarget.y, deltaSpeed ) == false )
			{
				int random = rand();
				distortTarget.y = ( random % 10 ) * distortAmount * size.width;
			}
		}
		
		return true;
	}
	
	return false;
}