Haoxiang Li | 0c07824 | 2020-06-10 16:59:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include <android/hardware/automotive/evs/1.1/IEvsCamera.h> |
| 20 | #include <system/camera_metadata.h> |
| 21 | |
| 22 | #include <string> |
| 23 | #include <vector> |
| 24 | |
Haoxiang Li | a9d23d1 | 2020-06-13 18:09:13 -0700 | [diff] [blame^] | 25 | #include "core_lib.h" |
| 26 | |
Haoxiang Li | 0c07824 | 2020-06-10 16:59:29 -0700 | [diff] [blame] | 27 | using ::android::hardware::automotive::evs::V1_1::IEvsCamera; |
Haoxiang Li | a9d23d1 | 2020-06-13 18:09:13 -0700 | [diff] [blame^] | 28 | using ::android_auto::surround_view::SurroundViewCameraParams; |
Haoxiang Li | 0c07824 | 2020-06-10 16:59:29 -0700 | [diff] [blame] | 29 | |
| 30 | namespace android { |
| 31 | namespace hardware { |
| 32 | namespace automotive { |
| 33 | namespace sv { |
| 34 | namespace V1_0 { |
| 35 | namespace implementation { |
| 36 | |
| 37 | const int kSizeLensDistortion = 5; |
| 38 | const int kSizeLensIntrinsicCalibration = 5; |
| 39 | const int kSizeLensPoseTranslation = 3; |
| 40 | const int kSizeLensPoseRotation = 4; |
| 41 | |
| 42 | // Camera parameters that the Android Camera team defines. |
| 43 | struct AndroidCameraParams { |
| 44 | float lensDistortion[kSizeLensDistortion]; |
| 45 | float lensIntrinsicCalibration[kSizeLensIntrinsicCalibration]; |
| 46 | float lensPoseTranslation[kSizeLensPoseTranslation]; |
| 47 | float lensPoseRotation[kSizeLensPoseRotation]; |
| 48 | }; |
| 49 | |
| 50 | // Gets the underlying physical camera ids for logical camera. |
| 51 | // If the given camera is not a logical, its own id will be returned. |
| 52 | std::vector<std::string> getPhysicalCameraIds(android::sp<IEvsCamera> camera); |
| 53 | |
| 54 | // Gets the intrinsic/extrinsic parameters for the given physical camera id. |
| 55 | // Returns true if the parameters are obtained successfully. Returns false |
| 56 | // otherwise. |
Haoxiang Li | a9d23d1 | 2020-06-13 18:09:13 -0700 | [diff] [blame^] | 57 | bool getAndroidCameraParams(android::sp<IEvsCamera> camera, |
| 58 | const std::string& cameraId, |
Haoxiang Li | 0c07824 | 2020-06-10 16:59:29 -0700 | [diff] [blame] | 59 | AndroidCameraParams& params); |
| 60 | |
Haoxiang Li | a9d23d1 | 2020-06-13 18:09:13 -0700 | [diff] [blame^] | 61 | // Converts the camera parameters from Android Camera format into Surround View |
| 62 | // core lib format. |
| 63 | std::vector<SurroundViewCameraParams> convertToSurroundViewCameraParams( |
| 64 | const std::map<std::string, AndroidCameraParams>& androidCameraParamsMap); |
| 65 | |
Haoxiang Li | 0c07824 | 2020-06-10 16:59:29 -0700 | [diff] [blame] | 66 | } // namespace implementation |
| 67 | } // namespace V1_0 |
| 68 | } // namespace sv |
| 69 | } // namespace automotive |
| 70 | } // namespace hardware |
| 71 | } // namespace android |