blob: 1fbc8d4d124f8549b3c92dfe0888963b1de17ed8 [file] [log] [blame]
Haoxiang Li0c078242020-06-10 16:59:29 -07001/*
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 Lia9d23d12020-06-13 18:09:13 -070025#include "core_lib.h"
26
Haoxiang Li0c078242020-06-10 16:59:29 -070027using ::android::hardware::automotive::evs::V1_1::IEvsCamera;
Haoxiang Lia9d23d12020-06-13 18:09:13 -070028using ::android_auto::surround_view::SurroundViewCameraParams;
Haoxiang Li0c078242020-06-10 16:59:29 -070029
30namespace android {
31namespace hardware {
32namespace automotive {
33namespace sv {
34namespace V1_0 {
35namespace implementation {
36
37const int kSizeLensDistortion = 5;
38const int kSizeLensIntrinsicCalibration = 5;
39const int kSizeLensPoseTranslation = 3;
40const int kSizeLensPoseRotation = 4;
41
42// Camera parameters that the Android Camera team defines.
43struct 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.
52std::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 Lia9d23d12020-06-13 18:09:13 -070057bool getAndroidCameraParams(android::sp<IEvsCamera> camera,
58 const std::string& cameraId,
Haoxiang Li0c078242020-06-10 16:59:29 -070059 AndroidCameraParams& params);
60
Haoxiang Lia9d23d12020-06-13 18:09:13 -070061// Converts the camera parameters from Android Camera format into Surround View
62// core lib format.
63std::vector<SurroundViewCameraParams> convertToSurroundViewCameraParams(
64 const std::map<std::string, AndroidCameraParams>& androidCameraParamsMap);
65
Haoxiang Li0c078242020-06-10 16:59:29 -070066} // namespace implementation
67} // namespace V1_0
68} // namespace sv
69} // namespace automotive
70} // namespace hardware
71} // namespace android