android native开发-native实现对camera的操作

本文介绍如何在Android中使用Native代码操作Camera,主要参考了frameworks/av/camera/ndk/及cts/tests/tests/graphics/jni/CameraTestHelpers.cpp的相关源码。
摘要由CSDN通过智能技术生成

通过native实现camera的操作

源码路径:frameworks/av/camera/ndk/
参考的test源码路径:cts/tests/tests/graphics/jni/CameraTestHelpers.cpp

1/*
2 * Copyright 2018 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
18#ifndef ANDROID_CAMERATESTHELPERS_H
19#define ANDROID_CAMERATESTHELPERS_H
20
21// Must come before NdkCameraCaptureSession.h
22#include <camera/NdkCaptureRequest.h>
23
24#include <camera/NdkCameraCaptureSession.h>
25#include <camera/NdkCameraDevice.h>
26#include <camera/NdkCameraError.h>
27#include <camera/NdkCameraManager.h>
28#include <cstdlib>
29#include <cstring>
30#include <jni.h>
31#include <media/NdkImage.h>
32#include <media/NdkImageReader.h>
33
34// A helper class which can be used to initialize/control the camera.
35class CameraHelper {
36public:
37  ~CameraHelper();
38
39  int initCamera(ANativeWindow *imgReaderAnw);
40  bool isCapabilitySupported(
41      acamera_metadata_enum_android_request_available_capabilities_t cap);
42  bool isCameraReady() { return mIsCameraReady; }
43  void closeCamera();
44  int takePicture();
45
46  static void onDeviceDisconnected(void * /*obj*/, ACameraDevice * /*device*/) {
47  }
48  static void onDeviceError(void * /*obj*/, ACameraDevice * /*device*/,
49                            int /*errorCode*/) {}
50  static void onSessionClosed(void * /*ob
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值