void CMUCamera::setFeature(CameraFeature Feature, int Value, bool bIgnoreOldValue) { if (bIgnoreOldValue || m_Features[Feature] != Value) { m_Features[Feature] = Value; if (Feature == CAM_FEATURE_STROBE_DURATION) { if (m_pCamera->HasStrobe()) { C1394CameraControlStrobe* pControl = m_pCamera->GetStrobeControl(0); int err = pControl->SetValue(Value); checkCMUWarning(err == CAM_SUCCESS, "Error setting camera strobe."); } else { AVG_TRACE(Logger::WARNING, "Camera does not support strobe."); } } else { CAMERA_FEATURE cmuFeature = getFeatureID(Feature); if (m_pCamera->HasFeature(cmuFeature)) { bool bAuto = (Value == -1); C1394CameraControl* pControl = m_pCamera->GetCameraControl(cmuFeature); int err1 = pControl->SetAutoMode(bAuto); int err2 = CAM_SUCCESS; if (!bAuto) { err2 = pControl->SetValue(Value); } checkCMUWarning(err1 == CAM_SUCCESS && err2 == CAM_SUCCESS, string("Error setting camera feature: ") + cameraFeatureToString(Feature)); } else { AVG_TRACE(Logger::WARNING, string("Camera does not support feature: ") + cameraFeatureToString(Feature)); } } } }
void CMUCamera::setFeatureOneShot(CameraFeature Feature) { CAMERA_FEATURE cmuFeature = getFeatureID(Feature); if (cmuFeature != FEATURE_INVALID_FEATURE && m_pCamera->HasFeature(cmuFeature)) { C1394CameraControl* pControl = m_pCamera->GetCameraControl(cmuFeature); int err1 = pControl->SetOnOff(false); int err2 = pControl->SetAutoMode(false); int err3 = pControl->SetOnePush(true); checkCMUWarning(err1 == CAM_SUCCESS && err2 == CAM_SUCCESS && err3 == CAM_SUCCESS, string("Error setting feature: ") + cameraFeatureToString(Feature)); } else { AVG_TRACE(Logger::WARNING, string("Camera does not support feature: ") + cameraFeatureToString(Feature)); } }
void FWCamera::setFeatureOneShot(CameraFeature feature) { #ifdef AVG_ENABLE_1394_2 dc1394feature_t featureID = getFeatureID(feature); dc1394error_t err = dc1394_feature_set_mode(m_pCamera, featureID, DC1394_FEATURE_MODE_ONE_PUSH_AUTO); if (err != DC1394_SUCCESS) { AVG_LOG_WARNING("Camera: Unable to set one-shot for " << cameraFeatureToString(feature) << ". Error was " << err); } #endif }
void CMUCamera::internalGetFeature(CameraFeature Feature, unsigned short* val1, unsigned short* val2) const { *val1 = -1; *val2 = -1; CAMERA_FEATURE cmuFeature = getFeatureID(Feature); if (m_pCamera->HasFeature(cmuFeature)) { C1394CameraControl* pControl = m_pCamera->GetCameraControl(cmuFeature); pControl->Status(); pControl->GetValue(val1, val2); } else { AVG_TRACE(Logger::WARNING, string("Error reading camera feature: ") + cameraFeatureToString(Feature)); } }
void CMUCamera::setWhitebalance(int u, int v, bool bIgnoreOldValue) { if (bIgnoreOldValue || m_WhitebalanceU != u || m_WhitebalanceV != v) { m_WhitebalanceU = u; m_WhitebalanceV = v; CAMERA_FEATURE cmuFeature = getFeatureID(CAM_FEATURE_WHITE_BALANCE); if (m_pCamera->HasFeature(FEATURE_WHITE_BALANCE)) { bool bAuto = (u == -1); C1394CameraControl* pControl = m_pCamera->GetCameraControl(cmuFeature); int err1 = pControl->SetAutoMode(bAuto); int err2 = CAM_SUCCESS; if (!bAuto) { err2 = pControl->SetValue(u, v); } checkCMUWarning(err1 == CAM_SUCCESS && err2 == CAM_SUCCESS, string("Error setting camera feature: ") + cameraFeatureToString(CAM_FEATURE_WHITE_BALANCE)); } else { AVG_TRACE(Logger::WARNING, string("Camera does not support feature: ") + cameraFeatureToString(CAM_FEATURE_WHITE_BALANCE)); } } }
void FWCamera::getCameraControls(dc1394camera_t* pCamera, CameraInfo* camInfo) { dc1394featureset_t featureSet; int err = dc1394_feature_get_all(pCamera, &featureSet); if (err != DC1394_SUCCESS) { AVG_ASSERT(false); return; } for (int i = DC1394_FEATURE_MIN; i <= DC1394_FEATURE_MAX; i++) { dc1394feature_info_t featureInfo = featureSet.feature[i - DC1394_FEATURE_MIN]; dc1394bool_t bool_t; dc1394_feature_is_present(pCamera,featureInfo.id, &bool_t); if (bool_t != DC1394_TRUE) { continue; } uint32_t min = -1; uint32_t max = -1; uint32_t actValue = -1; //TODO: 428 (TRIGGER) doesnt have min max err = dc1394_feature_get_boundaries(pCamera, featureInfo.id, &min, &max); if (err != DC1394_SUCCESS) { continue; } switch(featureInfo.id) { case DC1394_FEATURE_TEMPERATURE: { uint32_t targetTemp = -1; uint32_t currentTemp = -1; err = dc1394_feature_temperature_get_value(pCamera,&targetTemp,¤tTemp); if (err != DC1394_SUCCESS) { continue; } actValue = currentTemp; break; } //TODO: Think about a way to get this information into CameraInfo case DC1394_FEATURE_WHITE_BALANCE: { uint32_t ubValue = -1; uint32_t vrValue = -1; err = dc1394_feature_whitebalance_get_value(pCamera,&ubValue,&vrValue); if (err != DC1394_SUCCESS) { continue; } //actValue = ubValue; //vrValue; //cout <<"UBlue Value: " << ubValue << " VRed Value: " << vrValue << endl; break; } default: { err = dc1394_feature_get_value(pCamera,featureInfo.id, &actValue); if (err != DC1394_SUCCESS) { continue; } break; } } CameraFeature enumFeature = featureIDToEnum(featureInfo.id); if (enumFeature == CAM_FEATURE_UNSUPPORTED) { continue; } std::string controlName = cameraFeatureToString(enumFeature); CameraControl control = CameraControl(controlName, (int) min, (int) max, (int) actValue ); //TODO: isnt really a default value!? camInfo->addControl(control); } }