• 基于android的 rk3399 同时支持多个USB摄像头


    一、前文

    Android系统默认支持2个摄像头,一个前置摄像头,一个后置摄像头
    需要支持数量更多的摄像头,得修改Android Hal层的代码
    
    • 1
    • 2

    在这里插入图片描述

    二、CameraHal_Module.h

    修改CAMERAS_SUPPORT_MAX
    
    • 1

    在这里插入图片描述

    三、CameraHal_Module.cpp

    修改camera_get_number_of_cameras()函数中变量camInfoTmp[]相关代码
    
    • 1

    在这里插入图片描述

    在这里插入图片描述

    在这里插入图片描述

    四、编译&烧录Image

    该部分的修改要生效的话,需要进行全编译

        ./build.sh
        ./build.sh mkimage
        ./build.sh mkupdate
    
    • 1
    • 2
    • 3

    五、App验证

    AndroidManifest.xml

    
    
    
    
    
    
    
     
    
    
    
    	
    						
    						
    						
    	
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    MainActivity.java

    package com.example.cameraapplication;
    import androidx.appcompat.app.AppCompatActivity;
    import android.hardware.Camera;
    import android.os.Bundle;
    import android.view.SurfaceHolder;
    import android.view.SurfaceView;
    import android.widget.Toast;import java.util.ArrayList;
    import java.util.List;
    public class MainActivity extends AppCompatActivity {
    private static final String TAG = MainActivity.class.getSimpleName();
    Camera camera1, camera2, camera3, camera4;
    SurfaceHolder surfaceHolder1, surfaceHolder2, surfaceHolder3, surfaceHolder4;
    SurfaceView surfaceView1, surfaceView2, surfaceView3, surfaceView4;
    List cameraList = new ArrayList<>();
    List surfaceHolderList = new ArrayList<>();
    List surfaceViewList = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        surfaceView1 = findViewById(R.id.camera_surface_view1);
        surfaceView2 = findViewById(R.id.camera_surface_view2);
        surfaceView3 = findViewById(R.id.camera_surface_view3);
        surfaceView4 = findViewById(R.id.camera_surface_view4);
        cameraList.add(camera1);
        cameraList.add(camera2);
        cameraList.add(camera3);
        cameraList.add(camera4);
        surfaceHolderList.add(surfaceHolder1);
        surfaceHolderList.add(surfaceHolder2);
        surfaceHolderList.add(surfaceHolder3);
        surfaceHolderList.add(surfaceHolder4);
        surfaceViewList.add(surfaceView1);
        surfaceViewList.add(surfaceView2);
        surfaceViewList.add(surfaceView3);
        surfaceViewList.add(surfaceView4);
        for(int i=0; i
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95

    activity_main.xml

    
    
    
    
    
    
    
    
    
    
    
    
    
        
        
    
    
        
        
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
  • 相关阅读:
    【004】Shell脚本以怎样的方式执行?
    Java基础之《Ajax+JQuery(JavaEE开发进阶Ⅱ)》—JQuery与Ajax的应用(2)
    android 13.0 添加系统字体并且设置为默认字体
    代码随想录刷题记录 6 - 二叉树(1)
    【兔子王赠书第2期】《案例学Python(基础篇)》
    SPI机制
    第27集丨心学&禅宗:修行就是“做减法”
    触摸屏驱动
    VMWare的安装,创建虚拟机及安装CentOS图文详细步骤(内含VMWare安装包,CentOS安装包)
    【深度度优先搜索】leetcode 797. 所有可能的路径
  • 原文地址:https://blog.csdn.net/hnjzfwy/article/details/134042887