Loading services/camera/libcameraservice/device3/Camera3OutputUtils.cpp +27 −1 Original line number Diff line number Diff line Loading @@ -182,8 +182,34 @@ void sendPartialCaptureResult(CaptureOutputStates& states, return; } // Update partial result by removing keys remapped by DistortionCorrection, ZoomRatio, // and RotationAndCrop mappers. std::set<uint32_t> keysToRemove; auto iter = states.distortionMappers.find(states.cameraId.c_str()); if (iter != states.distortionMappers.end()) { const auto& remappedKeys = iter->second.getRemappedKeys(); keysToRemove.insert(remappedKeys.begin(), remappedKeys.end()); } const auto& remappedKeys = states.zoomRatioMappers[states.cameraId.c_str()].getRemappedKeys(); keysToRemove.insert(remappedKeys.begin(), remappedKeys.end()); auto mapper = states.rotateAndCropMappers.find(states.cameraId.c_str()); if (mapper != states.rotateAndCropMappers.end()) { const auto& remappedKeys = iter->second.getRemappedKeys(); keysToRemove.insert(remappedKeys.begin(), remappedKeys.end()); } for (uint32_t key : keysToRemove) { captureResult.mMetadata.erase(key); } // Send partial result if (captureResult.mMetadata.entryCount() > 0) { insertResultLocked(states, &captureResult, frameNumber); } } void sendCaptureResult( CaptureOutputStates& states, Loading services/camera/libcameraservice/device3/CoordinateMapper.h +14 −3 Original line number Diff line number Diff line Loading @@ -18,16 +18,23 @@ #define ANDROID_SERVERS_COORDINATEMAPPER_H #include <array> #include <set> namespace android { namespace camera3 { class CoordinateMapper { // Right now only stores metadata tags containing 2D coordinates // to be corrected. public: // The result metadata tags that are to be re-mapped const std::set<uint32_t>& getRemappedKeys() const { return mRemappedKeys; } virtual ~CoordinateMapper() = default; protected: // Metadata key lists to correct // Metadata tags containing 2D coordinates to be corrected. // Both capture request and result static const std::array<uint32_t, 3> kMeteringRegionsToCorrect; Loading @@ -37,6 +44,10 @@ protected: // Only for capture results; don't clamp static const std::array<uint32_t, 2> kResultPointsToCorrectNoClamp; virtual void initRemappedKeys() = 0; std::set<uint32_t> mRemappedKeys; }; // class CoordinateMapper } // namespace camera3 Loading services/camera/libcameraservice/device3/DistortionMapper.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,20 @@ namespace camera3 { DistortionMapper::DistortionMapper() : mValidMapping(false), mValidGrids(false) { initRemappedKeys(); } void DistortionMapper::initRemappedKeys() { mRemappedKeys.insert( kMeteringRegionsToCorrect.begin(), kMeteringRegionsToCorrect.end()); mRemappedKeys.insert( kRectsToCorrect.begin(), kRectsToCorrect.end()); mRemappedKeys.insert( kResultPointsToCorrectNoClamp.begin(), kResultPointsToCorrectNoClamp.end()); mRemappedKeys.insert(ANDROID_DISTORTION_CORRECTION_MODE); } bool DistortionMapper::isDistortionSupported(const CameraMetadata &deviceInfo) { Loading services/camera/libcameraservice/device3/DistortionMapper.h +5 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ namespace camera3 { * Utilities to transform between raw (distorted) and warped (corrected) coordinate systems * for cameras that support geometric distortion */ class DistortionMapper : private CoordinateMapper { class DistortionMapper : public CoordinateMapper { public: DistortionMapper(); Loading @@ -43,7 +43,10 @@ class DistortionMapper : private CoordinateMapper { mArrayWidth(other.mArrayWidth), mArrayHeight(other.mArrayHeight), mActiveWidth(other.mActiveWidth), mActiveHeight(other.mActiveHeight), mArrayDiffX(other.mArrayDiffX), mArrayDiffY(other.mArrayDiffY), mCorrectedGrid(other.mCorrectedGrid), mDistortedGrid(other.mDistortedGrid) {} mCorrectedGrid(other.mCorrectedGrid), mDistortedGrid(other.mDistortedGrid) { initRemappedKeys(); } void initRemappedKeys() override; /** * Check whether distortion correction is supported by the camera HAL Loading services/camera/libcameraservice/device3/RotateAndCropMapper.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,18 @@ namespace android { namespace camera3 { void RotateAndCropMapper::initRemappedKeys() { mRemappedKeys.insert( kMeteringRegionsToCorrect.begin(), kMeteringRegionsToCorrect.end()); mRemappedKeys.insert( kResultPointsToCorrectNoClamp.begin(), kResultPointsToCorrectNoClamp.end()); mRemappedKeys.insert(ANDROID_SCALER_ROTATE_AND_CROP); mRemappedKeys.insert(ANDROID_SCALER_CROP_REGION); } bool RotateAndCropMapper::isNeeded(const CameraMetadata* deviceInfo) { auto entry = deviceInfo->find(ANDROID_SCALER_AVAILABLE_ROTATE_AND_CROP_MODES); for (size_t i = 0; i < entry.count; i++) { Loading @@ -36,6 +48,8 @@ bool RotateAndCropMapper::isNeeded(const CameraMetadata* deviceInfo) { } RotateAndCropMapper::RotateAndCropMapper(const CameraMetadata* deviceInfo) { initRemappedKeys(); auto entry = deviceInfo->find(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE); if (entry.count != 4) return; Loading Loading
services/camera/libcameraservice/device3/Camera3OutputUtils.cpp +27 −1 Original line number Diff line number Diff line Loading @@ -182,8 +182,34 @@ void sendPartialCaptureResult(CaptureOutputStates& states, return; } // Update partial result by removing keys remapped by DistortionCorrection, ZoomRatio, // and RotationAndCrop mappers. std::set<uint32_t> keysToRemove; auto iter = states.distortionMappers.find(states.cameraId.c_str()); if (iter != states.distortionMappers.end()) { const auto& remappedKeys = iter->second.getRemappedKeys(); keysToRemove.insert(remappedKeys.begin(), remappedKeys.end()); } const auto& remappedKeys = states.zoomRatioMappers[states.cameraId.c_str()].getRemappedKeys(); keysToRemove.insert(remappedKeys.begin(), remappedKeys.end()); auto mapper = states.rotateAndCropMappers.find(states.cameraId.c_str()); if (mapper != states.rotateAndCropMappers.end()) { const auto& remappedKeys = iter->second.getRemappedKeys(); keysToRemove.insert(remappedKeys.begin(), remappedKeys.end()); } for (uint32_t key : keysToRemove) { captureResult.mMetadata.erase(key); } // Send partial result if (captureResult.mMetadata.entryCount() > 0) { insertResultLocked(states, &captureResult, frameNumber); } } void sendCaptureResult( CaptureOutputStates& states, Loading
services/camera/libcameraservice/device3/CoordinateMapper.h +14 −3 Original line number Diff line number Diff line Loading @@ -18,16 +18,23 @@ #define ANDROID_SERVERS_COORDINATEMAPPER_H #include <array> #include <set> namespace android { namespace camera3 { class CoordinateMapper { // Right now only stores metadata tags containing 2D coordinates // to be corrected. public: // The result metadata tags that are to be re-mapped const std::set<uint32_t>& getRemappedKeys() const { return mRemappedKeys; } virtual ~CoordinateMapper() = default; protected: // Metadata key lists to correct // Metadata tags containing 2D coordinates to be corrected. // Both capture request and result static const std::array<uint32_t, 3> kMeteringRegionsToCorrect; Loading @@ -37,6 +44,10 @@ protected: // Only for capture results; don't clamp static const std::array<uint32_t, 2> kResultPointsToCorrectNoClamp; virtual void initRemappedKeys() = 0; std::set<uint32_t> mRemappedKeys; }; // class CoordinateMapper } // namespace camera3 Loading
services/camera/libcameraservice/device3/DistortionMapper.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,20 @@ namespace camera3 { DistortionMapper::DistortionMapper() : mValidMapping(false), mValidGrids(false) { initRemappedKeys(); } void DistortionMapper::initRemappedKeys() { mRemappedKeys.insert( kMeteringRegionsToCorrect.begin(), kMeteringRegionsToCorrect.end()); mRemappedKeys.insert( kRectsToCorrect.begin(), kRectsToCorrect.end()); mRemappedKeys.insert( kResultPointsToCorrectNoClamp.begin(), kResultPointsToCorrectNoClamp.end()); mRemappedKeys.insert(ANDROID_DISTORTION_CORRECTION_MODE); } bool DistortionMapper::isDistortionSupported(const CameraMetadata &deviceInfo) { Loading
services/camera/libcameraservice/device3/DistortionMapper.h +5 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ namespace camera3 { * Utilities to transform between raw (distorted) and warped (corrected) coordinate systems * for cameras that support geometric distortion */ class DistortionMapper : private CoordinateMapper { class DistortionMapper : public CoordinateMapper { public: DistortionMapper(); Loading @@ -43,7 +43,10 @@ class DistortionMapper : private CoordinateMapper { mArrayWidth(other.mArrayWidth), mArrayHeight(other.mArrayHeight), mActiveWidth(other.mActiveWidth), mActiveHeight(other.mActiveHeight), mArrayDiffX(other.mArrayDiffX), mArrayDiffY(other.mArrayDiffY), mCorrectedGrid(other.mCorrectedGrid), mDistortedGrid(other.mDistortedGrid) {} mCorrectedGrid(other.mCorrectedGrid), mDistortedGrid(other.mDistortedGrid) { initRemappedKeys(); } void initRemappedKeys() override; /** * Check whether distortion correction is supported by the camera HAL Loading
services/camera/libcameraservice/device3/RotateAndCropMapper.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,18 @@ namespace android { namespace camera3 { void RotateAndCropMapper::initRemappedKeys() { mRemappedKeys.insert( kMeteringRegionsToCorrect.begin(), kMeteringRegionsToCorrect.end()); mRemappedKeys.insert( kResultPointsToCorrectNoClamp.begin(), kResultPointsToCorrectNoClamp.end()); mRemappedKeys.insert(ANDROID_SCALER_ROTATE_AND_CROP); mRemappedKeys.insert(ANDROID_SCALER_CROP_REGION); } bool RotateAndCropMapper::isNeeded(const CameraMetadata* deviceInfo) { auto entry = deviceInfo->find(ANDROID_SCALER_AVAILABLE_ROTATE_AND_CROP_MODES); for (size_t i = 0; i < entry.count; i++) { Loading @@ -36,6 +48,8 @@ bool RotateAndCropMapper::isNeeded(const CameraMetadata* deviceInfo) { } RotateAndCropMapper::RotateAndCropMapper(const CameraMetadata* deviceInfo) { initRemappedKeys(); auto entry = deviceInfo->find(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE); if (entry.count != 4) return; Loading