root / branches / test / CCV_Select_Camera / addons / ofxCameraBase / src / ofxCameraBaseSettings.cpp @ 124
View | Annotate | Download (3.9 KB)
| 1 | /*
|
|---|---|
| 2 | * ofxCameraBaseSettings.cpp |
| 3 | * |
| 4 | * |
| 5 | * Created by Yishi Guo on 07/30/2011. |
| 6 | * Copyright 2011 NUI Group. All right reserved. |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | #include "ofxCameraBaseSettings.h" |
| 11 | |
| 12 | std::string CameraTypeToStr( const CAMERATYPE &type ) {
|
| 13 | std::string str = "NULL";
|
| 14 | switch ( type ) {
|
| 15 | case PS3: |
| 16 | str = "PS3";
|
| 17 | break;
|
| 18 | case CMU: |
| 19 | str = "CMU";
|
| 20 | break;
|
| 21 | case FFMV: |
| 22 | str = "FFMV";
|
| 23 | break;
|
| 24 | case DIRECTSHOW: |
| 25 | str = "DIRECTSHOW";
|
| 26 | break;
|
| 27 | case KINECT: |
| 28 | str = "KINECT";
|
| 29 | break;
|
| 30 | default:
|
| 31 | break;
|
| 32 | } |
| 33 | |
| 34 | return str;
|
| 35 | } |
| 36 | |
| 37 | CAMERATYPE StrToCameraType( const std::string &str ) {
|
| 38 | CAMERATYPE type = PS3; |
| 39 | if ( str == "PS3" ) { |
| 40 | type = PS3; |
| 41 | } else if ( str == "FFMV" ) { |
| 42 | type = FFMV; |
| 43 | } else if ( str == "CMU" ) { |
| 44 | type = CMU; |
| 45 | } else if ( str == "DIRECTSHOW" ) { |
| 46 | type = DIRECTSHOW; |
| 47 | } else if ( str == "KINECT" ) { |
| 48 | type = KINECT; |
| 49 | } |
| 50 | |
| 51 | return type;
|
| 52 | } |
| 53 | |
| 54 | ofxCameraBaseSettings& ofxCameraBaseSettings::operator=( const ofxCameraBaseSettings &temp ) {
|
| 55 | this->cameraGuid = temp.cameraGuid; |
| 56 | this->cameraType = temp.cameraType; |
| 57 | this->pixelMode = temp.pixelMode; |
| 58 | this->cameraDepth = temp.cameraDepth; |
| 59 | this->cameraX = temp.cameraX; |
| 60 | this->cameraY = temp.cameraY; |
| 61 | this->cameraWidth = temp.cameraWidth; |
| 62 | this->cameraHeight = temp.cameraHeight; |
| 63 | this->cameraLeft = temp.cameraLeft; |
| 64 | this->cameraTop = temp.cameraTop; |
| 65 | this->cameraIndex = temp.cameraIndex; |
| 66 | this->cameraFramerate = temp.cameraFramerate; |
| 67 | this->videoPlayerOn = temp.videoPlayerOn; |
| 68 | this->videoRecorderOn = temp.videoRecorderOn; |
| 69 | this->isPropertyOn = temp.isPropertyOn; |
| 70 | this->isPropertyAuto = temp.isPropertyAuto; |
| 71 | this->propertyFirstValue = temp.propertyFirstValue; |
| 72 | this->propertySecondValue = temp.propertySecondValue; |
| 73 | this->propertyType = temp.propertyType; |
| 74 | this->calibrationPoints = temp.calibrationPoints; |
| 75 | //int i;
|
| 76 | //for ( i = 0; i < isPropertyAuto.size(); ++i ) {
|
| 77 | // this->isPropertyAuto[i] = temp.isPropertyAuto[i];
|
| 78 | //}
|
| 79 | //for ( i = 0; i < isPropertyOn.size(); ++i ) {
|
| 80 | // this->isPropertyOn[i] = temp.isPropertyOn[i];
|
| 81 | //}
|
| 82 | //for ( i = 0; i < propertyFirstValue.size(); ++i ) {
|
| 83 | // this->propertyFirstValue[i] = temp.propertyFirstValue[i];
|
| 84 | //}
|
| 85 | //for ( i = 0; i < propertyFirstValue.size(); ++i ) {
|
| 86 | // this->propertySecondValue[i] = temp.propertySecondValue[i];
|
| 87 | //}
|
| 88 | //for ( i = 0; i < propertyType.size(); ++i ) {
|
| 89 | // this->propertyType[i] = temp.propertyType[i];
|
| 90 | //}
|
| 91 | //for ( i = 0; i < calibrationPoints.size(); ++i ) {
|
| 92 | // this->calibrationPoints[i] = temp.calibrationPoints[i];
|
| 93 | //}
|
| 94 | |
| 95 | return *this;
|
| 96 | } |
| 97 | |
| 98 | void ofxCameraBaseSettings::setFeature( const CAMERA_BASE_FEATURE &feature, const int &firstValue, const int &secondValue, const bool &isAuto, const bool &isEnable ) { |
| 99 | for ( int i = 0; i < propertyType.size(); ++i ) { |
| 100 | if ( propertyType[i] == feature ) {
|
| 101 | propertyFirstValue[i] = firstValue; |
| 102 | propertySecondValue[i] = secondValue; |
| 103 | isPropertyAuto[i] = isAuto; |
| 104 | isPropertyOn[i] = isEnable; |
| 105 | |
| 106 | break;
|
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | int ofxCameraBaseSettings::getFirstValue( const CAMERA_BASE_FEATURE &feature ) { |
| 112 | for ( int i = 0; i < propertyType.size(); ++i ) { |
| 113 | if ( propertyType[i] == feature ) {
|
| 114 | return propertyFirstValue[i];
|
| 115 | } |
| 116 | } |
| 117 | |
| 118 | return -1; |
| 119 | } |
| 120 | int ofxCameraBaseSettings::getSecondValue( const CAMERA_BASE_FEATURE &feature ) { |
| 121 | for ( int i = 0; i < propertyType.size(); ++i ) { |
| 122 | if ( propertyType[i] == feature ) {
|
| 123 | return propertySecondValue[i];
|
| 124 | } |
| 125 | } |
| 126 | |
| 127 | return -1; |
| 128 | } |
| 129 | bool ofxCameraBaseSettings::isFeatureAuto( const CAMERA_BASE_FEATURE &feature ) { |
| 130 | for ( int i = 0; i < propertyType.size(); ++i ) { |
| 131 | if ( propertyType[i] == feature ) {
|
| 132 | return isPropertyAuto[i];
|
| 133 | } |
| 134 | } |
| 135 | |
| 136 | return false; |
| 137 | } |
| 138 | bool ofxCameraBaseSettings::isFeatureOn( const CAMERA_BASE_FEATURE &feature ) { |
| 139 | int errorResult = -1; |
| 140 | for ( int i = 0; i < propertyType.size(); ++i ) { |
| 141 | if ( propertyType[i] == feature ) {
|
| 142 | return isPropertyOn[i];
|
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return false; |
| 147 | } |
