[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN113448648A - Linux-compatible Android camera access method and device - Google Patents

Linux-compatible Android camera access method and device Download PDF

Info

Publication number
CN113448648A
CN113448648A CN202110726443.9A CN202110726443A CN113448648A CN 113448648 A CN113448648 A CN 113448648A CN 202110726443 A CN202110726443 A CN 202110726443A CN 113448648 A CN113448648 A CN 113448648A
Authority
CN
China
Prior art keywords
camera
android
linux
camera information
container
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110726443.9A
Other languages
Chinese (zh)
Inventor
何勇
邱旭
姚宏亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jide Technology Research Institute Wuhan Co ltd
Original Assignee
Jide Technology Research Institute Wuhan Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jide Technology Research Institute Wuhan Co ltd filed Critical Jide Technology Research Institute Wuhan Co ltd
Priority to CN202110726443.9A priority Critical patent/CN113448648A/en
Publication of CN113448648A publication Critical patent/CN113448648A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/617Upgrading or updating of programs or applications for camera control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45562Creating, deleting, cloning virtual machine instances

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Studio Devices (AREA)

Abstract

本发明公开了一种Linux兼容Android的访问摄像头方法及装置,在Linux上创建容器,将Linux侧的摄像头挂载到容器内;在Android侧启用相机框架服务,轮询扫描/dev目录下的设备,筛选出摄像头;相机框架服务发送通知消息到Android侧的HAL层,HAL层缓存摄像头信息;Android系统的相机框架服务将单个摄像头虚拟成一个前置摄像头和一个后置摄像头,相机框架服务将虚拟的前置摄像头和后置摄像头的信息通过接口通知HAL层,Android应用访问摄像头。本发明对Linux操作系统的生态扩展起到了不可估量的作用。

Figure 202110726443

The invention discloses a Linux-compatible Android-compatible camera access method and device. A container is created on Linux, and a camera on the Linux side is mounted in the container; a camera framework service is enabled on the Android side, and devices in the /dev directory are polled and scanned. , filter out cameras; the camera framework service sends notification messages to the HAL layer on the Android side, and the HAL layer caches camera information; the camera framework service of the Android system virtualizes a single camera into a front camera and a rear camera, and the camera framework service virtualizes The information of the front camera and the rear camera is notified to the HAL layer through the interface, and the Android application accesses the camera. The present invention plays an immeasurable role in the ecological expansion of the Linux operating system.

Figure 202110726443

Description

Linux-compatible Android camera access method and device
Technical Field
The invention relates to the field of computer operating systems, in particular to a method and a device for accessing a camera with Linux compatible with Android.
Background
Since the Android application ecology becomes the largest application ecology in the world today, cross-platform operation of Android applications has become an industry trend. As is known, the problem of the Linux desktop operating system is that the application ecology is lacking, which also causes that the Linux desktop system cannot become the mainstream desktop operating system, so that the Android application is more and more accepted by the public to run on the Linux desktop system.
The Linux compatible Android environment is a technology for running Android applications (apps) on a Linux operating system, and has important significance for enriching the application ecology of the Linux operating system. The Linux compatible Android environment generally comprises a Host end and a Guest end, wherein the Host end runs on a Linux system and mainly comprises an Android container and a user interaction window, the Android container is used for isolating part of kernel resources from the Linux system to support the Guest end to run, the Guest end mainly comprises a specially customized Android application frame, an Android running library and the like, and Android applications run on the Guest end.
The PC provided with the Linux operating system and compatible with the Android environment can be internally provided with a camera and externally connected with the camera through a USB port, but the equipment belongs to the Linux system, and the Android environment in the container is the equipment without permission to access. In addition, the PC is different from the mobile device in that the mobile device does not support the USB port and supports the built-in camera, and hardware parameters of the camera are fixed, while the PC is not necessarily equipped with the built-in camera, and more than all the PC supports the camera through the external device of the USB port, and the hardware parameters of the USB camera are various. Up to now, the Android system does not support the USB camera, which results in that the Android application cannot use the USB camera in the Linux-compatible Android environment.
The Android system supports two cameras: the mobile equipment is characterized in that the front camera and the rear camera are adopted, two cameras are installed on all mobile equipment in the current market, one represents the front camera and the other represents the rear camera, and when a PC (personal computer) provided with a Linux operating system and compatible with an Android environment is inserted into a USB (universal serial bus) camera, the Android system cannot identify the types of the cameras and cannot operate the cameras.
Disclosure of Invention
In order to solve the problem that in a Linux Android-compatible environment, Android applications can use cameras (including USB cameras and built-in cameras) of a Linux system to complete operation of various functions of a front camera and a rear camera, the invention provides a Linux Android-compatible camera access method and device.
On one hand, the invention provides a method for accessing a camera by Linux compatible with Android, which is applied to an operation environment compatible with an Android system in Linux, and comprises the following steps:
step S1: creating a container on Linux, and mounting a camera on the Linux side into the container;
step S2: starting a container on Linux, and starting an Android system in the container;
step S3: starting a camera frame service at an Android side, polling and scanning equipment under a dev directory, and screening out a camera; the method comprises the steps that a camera framework service sends a notification message to an HAL layer on an Android side, and the HAL layer caches camera information;
step S4: the method comprises the steps that a camera framework service of an Android system virtualizes a single camera into a front camera and a rear camera, and the camera framework service informs information of the virtual front camera and the virtual rear camera to an HAL layer through an interface so that the camera of the Linux system is added to a front camera information list and a rear camera information list of the HAL layer;
step S5: and the Android application accesses the camera according to the front camera information list and the rear camera information list.
Further, the method starts a camera frame service on an Android side, polls equipment under a scanning/dev directory, and screens out the cameras, and specifically comprises the following steps:
starting a camera frame service at an Android side, polling and scanning equipment under a/dev directory, firstly judging whether equipment which is not processed by a system exists in the equipment under the/dev directory, if so, continuously judging whether the equipment which is not processed by the system supports a V42L specification, and if not, finishing scanning; if the device which is not processed by the system supports the V42L specification, the image capturing capability of the device is continuously judged, and if the device which is not processed by the system does not support the V42L specification, the device under the scanning/dev directory is continuously polled; when the image capturing capability of the equipment meets the system requirement, continuously judging whether the format of the data acquired by the equipment is supported by the system, and when the image capturing capability of the equipment does not meet the system requirement, continuously polling and scanning the equipment in the dev directory; if the format of the data collected by the equipment is supported by the system, caching the information of the camera, and if the format of the data collected by the equipment is not supported by the system, continuously polling the equipment under the scanning/dev directory until the scanning is finished.
Further, the camera framework service notifies the HAL layer of the information of the virtual front camera and the virtual rear camera through an interface, so that the cameras of the Linux system are added to the front camera information list and the rear camera information list of the HAL layer, specifically:
the camera framework service judges the virtual front camera information and the virtual rear camera information: if the virtual front camera information does not exist in the front camera information list, adding the virtual front camera information into the front camera information list, and if the virtual front camera information does not exist in the front camera information list, not adding the virtual front camera information; if the virtual rear camera information does not exist in the rear camera information list, adding the virtual rear camera information into the rear camera information list, and if the virtual rear camera information does not exist in the rear camera information list, not adding the virtual rear camera information; and the HAL layer informs the camera framework service of the updated front camera information list and the updated rear camera information list, and the camera framework service updates the camera information.
Further, the step S1 is creating a container on Linux, and mounting a Linux-side camera into the container, including: opening device rights to the container when the container is created; and mounting the cameras on the Linux side into the container through the control group.
Further, the step S5 accessing the camera by the Android application according to the front camera information list and the rear camera information list includes: when the Android application calls the camera, the camera frame service firstly judges whether the camera exists or not and whether the camera is occupied or not, if the camera exists and is not occupied, the HAL layer is informed, and the HAL layer opens the camera.
On the other hand, the invention provides a Linux-Android-compatible access camera device, which is applied to an operating environment compatible with an Android system on Linux, and comprises the following components:
a container creation unit to: creating a container on Linux, and mounting a camera on the Linux side into the container;
a container activation unit for: starting a container on Linux, and starting an Android system in the container;
a camera information cache processing unit configured to: starting a camera frame service at an Android side, polling and scanning equipment under a dev directory, and screening out a camera; the method comprises the steps that a camera framework service sends a notification message to an HAL layer on an Android side, and the HAL layer caches camera information;
a virtual camera unit to: the method comprises the steps that a camera framework service of an Android system virtualizes a single camera into a front camera and a rear camera, and the camera framework service informs information of the virtual front camera and the virtual rear camera to an HAL layer through an interface so that the camera of the Linux system is added to a front camera information list and a rear camera information list of the HAL layer;
an access camera unit to: and the Android application accesses the camera according to the front camera information list and the rear camera information list.
Further, the camera information cache processing unit is configured to:
starting a camera frame service at an Android side, polling and scanning equipment under a/dev directory, firstly judging whether equipment which is not processed by a system exists in the equipment under the/dev directory, if so, continuously judging whether the equipment which is not processed by the system supports a V42L specification, and if not, finishing scanning; if the device which is not processed by the system supports the V42L specification, the image capturing capability of the device is continuously judged, and if the device which is not processed by the system does not support the V42L specification, the device under the scanning/dev directory is continuously polled; when the image capturing capability of the equipment meets the system requirement, continuously judging whether the format of the data acquired by the equipment is supported by the system, and when the image capturing capability of the equipment does not meet the system requirement, continuously polling and scanning the equipment in the dev directory; if the format of the data collected by the equipment is supported by the system, caching the information of the camera, and if the format of the data collected by the equipment is not supported by the system, continuously polling the equipment under the scanning/dev directory until the scanning is finished.
Further, the virtual camera unit is to:
the camera framework service judges the virtual front camera information and the virtual rear camera information: if the virtual front camera information does not exist in the front camera information list, adding the virtual front camera information into the front camera information list, and if the virtual front camera information does not exist in the front camera information list, not adding the virtual front camera information; if the virtual rear camera information does not exist in the rear camera information list, adding the virtual rear camera information into the rear camera information list, and if the virtual rear camera information does not exist in the rear camera information list, not adding the virtual rear camera information; and the HAL layer informs the camera framework service of the updated front camera information list and the updated rear camera information list, and the camera framework service updates the camera information.
Further, the container creating unit is configured to: opening device rights to the container when the container is created; and mounting the cameras on the Linux side into the container through the control group.
Further, the access camera unit is to: when the Android application calls the camera, the camera frame service firstly judges whether the camera exists or not and whether the camera is occupied or not, if the camera exists and is not occupied, the HAL layer is informed, and the HAL layer opens the camera.
Compared with the prior art, the invention has the following advantages:
at present, most applications can use the camera to realize various functions, and the technical scheme of the invention solves the problem that no camera is available in the application of the Android system because no camera is arranged in the front and back of the Linux operating system compatible with the Android, so that the invention plays an immeasurable role in the ecological expansion of the Linux operating system. Meanwhile, the USB camera is detachable and replaceable, so that a selection space suitable for the camera is provided for a client.
Drawings
Fig. 1 is a schematic diagram of a method for accessing a camera with Linux compatible Android provided in an embodiment of the present invention;
fig. 2 is a schematic view illustrating a Linux-compatible Android access camera device according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a network architecture of a Linux-compatible Android virtual front camera and a Linux-compatible Android virtual rear camera provided in an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
For the operating environment compatible with Android running on the Linux operating system, the Android operating environment runs in a container.
Containers are a lightweight virtualization technology supported by the Linux kernel in recent years. A new Linux system (including other systems customized based on the Linux system, such as Android) can be operated in the Linux system through a container technology, and a client system and a host system are isolated from each other through the container. Different from the traditional scheme based on the virtual machine technology, in the container technology, the client system and the host system share resources such as a CPU (central processing unit), a memory, storage and the like, and the resource overhead is low. In addition, through proper configuration, the client system can directly access the hardware resource of the host, and the performance of the client system is further improved.
Due to the isolation effect of the container docker, Linux cannot access the internal storage directory of Android, and Android applications on Linux cannot directly access Linux-side files.
Fig. 1 is a schematic diagram of a method for accessing a camera with Linux compatible with Android, which is provided by an embodiment of the present invention, and is applied to an operation environment with Linux compatible with Android system, where the method includes the following steps:
step S1: creating a container on Linux, and mounting a camera on the Linux side into the container;
opening part of equipment access rights simultaneously when an Android environment container is created;
in an Android environment compatible with a Linux system, all hardware devices used in the Android environment are derived from the Linux system, and when the Android environment is restarted or started for the first time, the access right of the existing devices in the Linux system needs to be opened to the Android environment. For compatibly running the Android running environment on the Linux operating system, the Android running environment runs in a container, so that the HAL layer hardware abstraction layer of the Android has no right to directly access Linux system hardware equipment. The method can create the container through the existing Linux command, and directly opens the device authority to the container when the container is created, so that the Android environment has the capability of accessing the device authority.
The device files under the/dev directory of the Linux system are used to represent the peripherals, e.g./dev/video 0 represents the first media device (camera). However, this/dev/video 0 is only convenient for the user to observe, and the representation of different devices in the l inux kernel is realized by a major and a minor Number, and corresponding drivers are loaded through the major and the minor Number.
major number: indicating different device types
minor number: representing different partitions of the same device
For example:
Figure BDA0003138861430000071
the major numbers of the video0, the video1, the video2 and the video3 are all 81, the minor number of the video is 0, and 1 is added for each new camera minor number. It can be seen that we can represent cameras by major number 81. When the docker is used for creating the Android container, 81 device access rights can be opened to the Android container.
docker is a container technology that effectively partitions resources of a single operating system into isolated groups to better balance conflicting resource usage requirements among the isolated groups. In the Linux-compatible Android environment, the Android system runs in a docker container of a Linux end.
The container creation instruction (docker create) can create a docker container by docker mirroring, a — device-group-rule of docker create 'c 81: × rmw' parameter can mount a device group of which cgroup (control group) is 81 (camera device) into the docker container, and set the authority of the device group of which cgroup (control group) is 81 (camera device) so that the Android system running in the docker container has the authority to open and operate the device group of which Linux-side cgroup (control group) is 81 (camera device).
Cgroup (control groups) is a mechanism provided by the Linux kernel that can limit, record, and isolate the physical resources used by a process group. After a USB camera is connected to the Linux system, an equipment node with Cgroup of 81 (generally, dev/video0 or dev/video1, the name is not fixed) is generated. Therefore, when the container is created, the camera device at the Linux end can be mounted in the docker container through the parameter of-device-group-rule: 'c 81: × rmw'.
Step S2: starting a container on Linux, and starting an Android system in the container;
step S3: starting a camera frame service at an Android side, polling and scanning equipment under a dev directory, and screening out a camera; the method comprises the steps that a camera framework service sends a notification message to an HAL layer on an Android side, and the HAL layer caches camera information;
in the foregoing steps, when an Android container is created, access permissions of multiple devices in Linux are already openly shared to an Android environment, and we need to screen out camera devices from the devices and notify the camera devices to a HAL layer for caching for App to call, and meanwhile, a data format collected by the devices must be one of data formats allowed by a system.
The V4L2 is a set of video framework specially designed for Linux equipment, the main framework of the framework is an L inux kernel, and the data format collected by the equipment and the equipment for detection are based on the V4L2 command. The command of V4L2 will determine whether the current device and driver support the V4L2 specification, obtain the capability set of the device, and obtain the format supported by the device.
Step S4: the method comprises the steps that a camera framework service of an Android system virtualizes a single camera into a front camera and a rear camera, and the camera framework service informs information of the virtual front camera and the virtual rear camera to an HAL layer through an interface so that the camera of the Linux system is added to a front camera information list and a rear camera information list of the HAL layer;
in the Android system, two places are provided for caching the camera information of the system: android system camera framework, camera HAL layer. When the App calls the camera, the system camera frame firstly judges whether the camera exists or not and is occupied or not, if the camera which is not occupied exists, the camera is transferred to the HAL layer, and the HAL layer is requested to open the camera.
The Linux camera information is cached in the camera framework service in the previous steps, but the camera cannot be directly called by the App at the moment, because the Android system is basically oriented to the mobile device at present and only supports the operation of the camera through the ID 1 (front camera) and the ID 0 (rear camera), and there is no method for calling the camera with unknown ID at present. In actual operation, whether the App opens the front camera or the rear camera is determined by own business of the App, the PC is provided with built-in cameras possibly, and USB cameras with unknown numbers can be inserted.
Step S5: and the Android application accesses the camera according to the front camera information list and the rear camera information list.
Further, the method starts a camera frame service on an Android side, polls equipment under a scanning/dev directory, and screens out the cameras, and specifically comprises the following steps:
starting a camera frame service at an Android side, polling and scanning equipment under a/dev directory, firstly judging whether equipment which is not processed by a system exists in the equipment under the/dev directory, if so, continuously judging whether the equipment which is not processed by the system supports a V42L specification, and if not, finishing scanning; if the device which is not processed by the system supports the V42L specification, the image capturing capability of the device is continuously judged, and if the device which is not processed by the system does not support the V42L specification, the device under the scanning/dev directory is continuously polled; when the image capturing capability of the equipment meets the system requirement, continuously judging whether the format of the data acquired by the equipment is supported by the system, and when the image capturing capability of the equipment does not meet the system requirement, continuously polling and scanning the equipment in the dev directory; if the format of the data collected by the equipment is supported by the system, caching the information of the camera, and if the format of the data collected by the equipment is not supported by the system, continuously polling the equipment under the scanning/dev directory until the scanning is finished.
Further, the camera framework service notifies the HAL layer of the information of the virtual front camera and the virtual rear camera through an interface, so that the cameras of the Linux system are added to the front camera information list and the rear camera information list of the HAL layer, specifically:
the camera framework service judges the virtual front camera information and the virtual rear camera information: if the virtual front camera information does not exist in the front camera information list, adding the virtual front camera information into the front camera information list, and if the virtual front camera information does not exist in the front camera information list, not adding the virtual front camera information; if the virtual rear camera information does not exist in the rear camera information list, adding the virtual rear camera information into the rear camera information list, and if the virtual rear camera information does not exist in the rear camera information list, not adding the virtual rear camera information; and the HAL layer informs the camera framework service of the updated front camera information list and the updated rear camera information list, and the camera framework service updates the camera information.
Further, the step S1 is creating a container on Linux, and mounting a Linux-side camera into the container, including: opening device rights to the container when the container is created; and mounting the cameras on the Linux side into the container through the control group.
Further, the step S5 accessing the camera by the Android application according to the front camera information list and the rear camera information list includes: when the Android application calls the camera, the camera frame service firstly judges whether the camera exists or not and whether the camera is occupied or not, if the camera exists and is not occupied, the HAL layer is informed, and the HAL layer opens the camera.
Fig. 2 is a schematic view of a Linux-Android-compatible access camera device provided in an embodiment of the present invention, where the Linux-Android-compatible access camera device is applied in an operating environment where an Android system is compatibly operated on Linux, and the Linux-Android-compatible access camera device includes:
a container creation unit to: creating a container on Linux, and mounting a camera on the Linux side into the container;
a container activation unit for: starting a container on Linux, and starting an Android system in the container;
a camera information cache processing unit configured to: starting a camera frame service at an Android side, polling and scanning equipment under a dev directory, and screening out a camera; the method comprises the steps that a camera framework service sends a notification message to an HAL layer on an Android side, and the HAL layer caches camera information;
a virtual camera unit to: the method comprises the steps that a camera framework service of an Android system virtualizes a single camera into a front camera and a rear camera, and the camera framework service informs information of the virtual front camera and the virtual rear camera to an HAL layer through an interface so that the camera of the Linux system is added to a front camera information list and a rear camera information list of the HAL layer;
an access camera unit to: and the Android application accesses the camera according to the front camera information list and the rear camera information list.
Further, the camera information cache processing unit is configured to:
starting a camera frame service at an Android side, polling and scanning equipment under a/dev directory, firstly judging whether equipment which is not processed by a system exists in the equipment under the/dev directory, if so, continuously judging whether the equipment which is not processed by the system supports a V42L specification, and if not, finishing scanning; if the device which is not processed by the system supports the V42L specification, the image capturing capability of the device is continuously judged, and if the device which is not processed by the system does not support the V42L specification, the device under the scanning/dev directory is continuously polled; when the image capturing capability of the equipment meets the system requirement, continuously judging whether the format of the data acquired by the equipment is supported by the system, and when the image capturing capability of the equipment does not meet the system requirement, continuously polling and scanning the equipment in the dev directory; if the format of the data collected by the equipment is supported by the system, caching the information of the camera, and if the format of the data collected by the equipment is not supported by the system, continuously polling the equipment under the scanning/dev directory until the scanning is finished.
Further, the virtual camera unit is to:
the camera framework service judges the virtual front camera information and the virtual rear camera information: if the virtual front camera information does not exist in the front camera information list, adding the virtual front camera information into the front camera information list, and if the virtual front camera information does not exist in the front camera information list, not adding the virtual front camera information; if the virtual rear camera information does not exist in the rear camera information list, adding the virtual rear camera information into the rear camera information list, and if the virtual rear camera information does not exist in the rear camera information list, not adding the virtual rear camera information; and the HAL layer informs the camera framework service of the updated front camera information list and the updated rear camera information list, and the camera framework service updates the camera information.
Further, the container creating unit is configured to: opening device rights to the container when the container is created; and mounting the cameras on the Linux side into the container through the control group.
Further, the access camera unit is to: when the Android application calls the camera, the camera frame service firstly judges whether the camera exists or not and whether the camera is occupied or not, if the camera exists and is not occupied, the HAL layer is informed, and the HAL layer opens the camera.
Fig. 3 is a schematic diagram of a network architecture of a Linux-compatible Android virtual front camera and a Linux-compatible Android virtual rear camera provided in an embodiment of the present invention. In the figure, each camera (including a built-in camera and a USB camera) on the Linux system is added to a front camera information list and a rear camera information list, that is, the Linux camera is virtualized into a camera that can be supported by the Android system, and the Android application can be selected from the lists when the front camera or the rear camera is opened, so that multiple options are available.
Finally, it should be noted that: although the present invention has been described in detail with reference to the foregoing embodiments, it will be apparent to those skilled in the art that changes may be made in the embodiments and/or equivalents thereof without departing from the spirit and scope of the invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1.一种Linux兼容Android的访问摄像头方法,其特征在于,所述方法应用在Linux上兼容运行Android系统的运行环境下,所述方法包括如下步骤:1. a Linux compatible Android access camera method, is characterized in that, described method is applied under the operating environment of compatible running Android system on Linux, and described method may further comprise the steps: 步骤S1:在Linux上创建容器,将Linux侧的摄像头挂载到容器内;Step S1: Create a container on Linux, and mount the camera on the Linux side into the container; 步骤S2:在Linux上启动容器,在容器内启动Android系统;Step S2: start the container on Linux, and start the Android system in the container; 步骤S3:在Android侧启用相机框架服务,轮询扫描/dev目录下的设备,筛选出摄像头;相机框架服务发送通知消息到Android侧的HAL层,HAL层缓存摄像头信息;Step S3: Enable the camera framework service on the Android side, poll the devices under the /dev directory, and filter out cameras; the camera framework service sends a notification message to the HAL layer on the Android side, and the HAL layer caches the camera information; 步骤S4:Android系统的相机框架服务将单个摄像头虚拟成一个前置摄像头和一个后置摄像头,相机框架服务将虚拟的前置摄像头和后置摄像头的信息通过接口通知HAL层,以使Linux系统的摄像头被添加到HAL层的前置摄像头信息列表和后置摄像头信息列表;Step S4: The camera framework service of the Android system virtualizes a single camera into a front camera and a rear camera, and the camera framework service notifies the HAL layer of the virtual front camera and rear camera information through the interface, so that the Linux system can The camera is added to the front camera information list and rear camera information list of the HAL layer; 步骤S5:Android应用根据前置摄像头信息列表和后置摄像头信息列表访问摄像头。Step S5: The Android application accesses the camera according to the front camera information list and the rear camera information list. 2.如权利要求1所述的Linux兼容Android的访问摄像头方法,其特征在于,所述方法在Android侧启用相机框架服务,轮询扫描/dev目录下的设备,筛选出摄像头,具体包括:2. the access camera method of Linux compatible Android as claimed in claim 1, is characterized in that, described method enables camera frame service on Android side, polls the equipment under the scanning/dev directory, filters out camera, specifically comprises: 在Android侧启用相机框架服务,轮询扫描/dev目录下的设备,先判断/dev目录下的设备中是否存在未被系统处理的设备,若存在未被系统处理的设备,则继续判断未被系统处理的设备是否支持V42L规范,若不存在未被系统处理的设备,则结束扫描;若未被系统处理的设备支持V42L规范,则继续判断设备的图像捕捉能力,若未被系统处理的设备不支持V42L规范,则继续轮询扫描/dev目录下的设备;当设备的图像捕捉能力满足系统要求时,则继续判断设备采集数据的格式是否被系统支持,当设备的图像捕捉能力不满足系统要求时,继续轮询扫描/dev目录下的设备;若设备采集数据的格式被系统支持,则将摄像头信息缓存,若设备采集数据的格式不被系统支持,则继续轮询扫描/dev目录下的设备直至扫描完毕。Enable the camera framework service on the Android side, poll the devices in the /dev directory, and first determine whether there are devices in the /dev directory that have not been processed by the system. If there are devices that have not been processed by the system, continue to judge Whether the device processed by the system supports the V42L specification, if there is no device that has not been processed by the system, the scan will end; if the device not processed by the system supports the V42L specification, continue to judge the image capture capability of the device. If the V42L specification is not supported, continue to poll and scan the devices in the /dev directory; when the image capture capability of the device meets the system requirements, it continues to determine whether the format of the data collected by the device is supported by the system. When the image capture capability of the device does not meet the system requirements When required, continue to poll and scan the devices in the /dev directory; if the format of the data collected by the device is supported by the system, the camera information will be cached. If the format of the data collected by the device is not supported by the system, continue to poll and scan the /dev directory. device until the scan is complete. 3.如权利要求1所述的Linux兼容Android的访问摄像头方法,其特征在于,所述相机框架服务将虚拟的前置摄像头和后置摄像头的信息通过接口通知HAL层,以使Linux系统的摄像头被添加到HAL层的前置摄像头信息列表和后置摄像头信息列表,具体为:3. the access camera method of Linux compatible Android as claimed in claim 1, it is characterized in that, described camera frame service will inform HAL layer of the information of virtual front camera and rear camera by interface, so that the camera of Linux system is The front camera information list and the rear camera information list added to the HAL layer, specifically: 相机框架服务对虚拟的前置摄像头信息、后置摄像头信息进行判断:若前置摄像头信息列表中不存在虚拟的前置摄像头信息,则将虚拟的前置摄像头信息添加到前置摄像头信息列表,若存在则不添加;若后置摄像头信息列表中不存在虚拟的后置摄像头信息,则将虚拟的后置摄像头信息添加到后置摄像头信息列表,若存在则不添加;HAL层将更新后的前置摄像头信息列表和后置摄像头信息列表通知相机框架服务,相机框架服务对摄像头信息进行更新。The camera framework service judges the virtual front camera information and the rear camera information: if the virtual front camera information does not exist in the front camera information list, the virtual front camera information is added to the front camera information list. If it exists, it will not be added; if the virtual rear camera information does not exist in the rear camera information list, the virtual rear camera information will be added to the rear camera information list, if it exists, it will not be added; the HAL layer will update the The front camera information list and the rear camera information list notify the camera framework service, and the camera framework service updates the camera information. 4.如权利要求1所述的Linux兼容Android的访问摄像头方法,其特征在于,所述步骤S1在Linux上创建容器,将Linux侧的摄像头挂载到容器内,包括:在创建容器时将设备权限开放给容器;通过控制组群将Linux侧的摄像头挂载到容器内。4. the access camera method of Linux compatible Android as claimed in claim 1, is characterized in that, described step S1 creates container on Linux, and the camera of Linux side is mounted in container, comprises: when creating container, device The permissions are open to the container; the camera on the Linux side is mounted into the container through the control group. 5.如权利要求1所述的Linux兼容Android的访问摄像头方法,其特征在于,所述步骤S5Android应用根据前置摄像头信息列表和后置摄像头信息列表访问摄像头,包括:在Android应用调用摄像头时,相机框架服务首先判断摄像头是否存在以及摄像头是否被占用,如果存在且未被占用的摄像头,则通知HAL层,HAL层打开相机。5. the access camera method of Linux as claimed in claim 1 is compatible with Android, it is characterized in that, described step S5 Android application visits camera according to front camera information list and rear camera information list, comprising: when Android application calls camera, The camera framework service first determines whether the camera exists and whether the camera is occupied. If there is an unoccupied camera, it will notify the HAL layer, and the HAL layer will open the camera. 6.一种Linux兼容Android的访问摄像头装置,其特征在于,所述装置应用在Linux上兼容运行Android系统的运行环境下,所述装置包括:6. a Linux compatible access camera device of Android, is characterized in that, described device is applied under the operating environment of compatible running Android system on Linux, and described device comprises: 容器创建单元,用于:在Linux上创建容器,将Linux侧的摄像头挂载到容器内;The container creation unit is used to: create a container on Linux and mount the camera on the Linux side into the container; 容器启动单元,用于:在Linux上启动容器,在容器内启动Android系统;The container startup unit is used to: start the container on Linux, and start the Android system in the container; 相机信息缓存处理单元,用于:在Android侧启用相机框架服务,轮询扫描/dev目录下的设备,筛选出摄像头;相机框架服务发送通知消息到Android侧的HAL层,HAL层缓存摄像头信息;The camera information cache processing unit is used to: enable the camera framework service on the Android side, poll and scan the devices in the /dev directory, and filter out cameras; the camera framework service sends a notification message to the HAL layer on the Android side, and the HAL layer caches the camera information; 虚拟相机单元,用于:Android系统的相机框架服务将单个摄像头虚拟成一个前置摄像头和一个后置摄像头,相机框架服务将虚拟的前置摄像头和后置摄像头的信息通过接口通知HAL层,以使Linux系统的摄像头被添加到HAL层的前置摄像头信息列表和后置摄像头信息列表;The virtual camera unit is used for: The camera framework service of the Android system virtualizes a single camera into a front camera and a rear camera. The camera framework service notifies the HAL layer of the virtual front camera and rear camera information through the interface to The camera of the Linux system is added to the front camera information list and the rear camera information list of the HAL layer; 访问相机单元,用于:Android应用根据前置摄像头信息列表和后置摄像头信息列表访问摄像头。Access the camera unit for: Android applications to access the camera according to the front camera information list and the rear camera information list. 7.如权利要求6所述的Linux兼容Android的访问摄像头装置,其特征在于,所述相机信息缓存处理单元用于:7. the access camera device of Linux compatible Android as claimed in claim 6, is characterized in that, described camera information cache processing unit is used for: 在Android侧启用相机框架服务,轮询扫描/dev目录下的设备,先判断/dev目录下的设备中是否存在未被系统处理的设备,若存在未被系统处理的设备,则继续判断未被系统处理的设备是否支持V42L规范,若不存在未被系统处理的设备,则结束扫描;若未被系统处理的设备支持V42L规范,则继续判断设备的图像捕捉能力,若未被系统处理的设备不支持V42L规范,则继续轮询扫描/dev目录下的设备;当设备的图像捕捉能力满足系统要求时,则继续判断设备采集数据的格式是否被系统支持,当设备的图像捕捉能力不满足系统要求时,继续轮询扫描/dev目录下的设备;若设备采集数据的格式被系统支持,则将摄像头信息缓存,若设备采集数据的格式不被系统支持,则继续轮询扫描/dev目录下的设备直至扫描完毕。Enable the camera framework service on the Android side, poll the devices in the /dev directory, and first determine whether there are devices in the /dev directory that have not been processed by the system. If there are devices that have not been processed by the system, continue to judge Whether the device processed by the system supports the V42L specification, if there is no device that has not been processed by the system, the scan will end; if the device not processed by the system supports the V42L specification, continue to judge the image capture capability of the device. If the V42L specification is not supported, continue to poll and scan the devices in the /dev directory; when the image capture capability of the device meets the system requirements, it continues to determine whether the format of the data collected by the device is supported by the system. When the image capture capability of the device does not meet the system requirements When required, continue to poll and scan the devices in the /dev directory; if the format of the data collected by the device is supported by the system, the camera information will be cached. If the format of the data collected by the device is not supported by the system, continue to poll and scan the /dev directory. device until the scan is complete. 8.如权利要求6所述的Linux兼容Android的访问摄像头装置,其特征在于,所述虚拟相机单元用于:8. the access camera device of Linux compatible Android as claimed in claim 6, is characterized in that, described virtual camera unit is used for: 相机框架服务对虚拟的前置摄像头信息、后置摄像头信息进行判断:若前置摄像头信息列表中不存在虚拟的前置摄像头信息,则将虚拟的前置摄像头信息添加到前置摄像头信息列表,若存在则不添加;若后置摄像头信息列表中不存在虚拟的后置摄像头信息,则将虚拟的后置摄像头信息添加到后置摄像头信息列表,若存在则不添加;HAL层将更新后的前置摄像头信息列表和后置摄像头信息列表通知相机框架服务,相机框架服务对摄像头信息进行更新。The camera framework service judges the virtual front camera information and rear camera information: if the virtual front camera information does not exist in the front camera information list, the virtual front camera information is added to the front camera information list. If it exists, it will not be added; if there is no virtual rear camera information in the rear camera information list, the virtual rear camera information will be added to the rear camera information list, if it exists, it will not be added; the HAL layer will update the The front camera information list and the rear camera information list notify the camera framework service, and the camera framework service updates the camera information. 9.如权利要求6所述的Linux兼容Android的访问摄像头装置,其特征在于,所述容器创建单元用于:在创建容器时将设备权限开放给容器;通过控制组群将Linux侧的摄像头挂载到容器内。9. The access camera device of Linux compatible with Android as claimed in claim 6, wherein the container creation unit is used for: opening the device authority to the container when creating the container; hanging the camera on the Linux side by the control group loaded into the container. 10.如权利要求6所述的Linux兼容Android的访问摄像头装置,其特征在于,所述访问相机单元用于:在Android应用调用摄像头时,相机框架服务首先判断摄像头是否存在以及摄像头是否被占用,如果存在且未被占用的摄像头,则通知HAL层,HAL层打开相机。10. the access camera device of Linux compatible Android as claimed in claim 6, is characterized in that, described access camera unit is used for: when Android application calls camera, camera frame service first judges whether camera exists and camera is occupied, If there is an unoccupied camera, the HAL layer is notified, and the HAL layer turns on the camera.
CN202110726443.9A 2021-06-29 2021-06-29 Linux-compatible Android camera access method and device Pending CN113448648A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110726443.9A CN113448648A (en) 2021-06-29 2021-06-29 Linux-compatible Android camera access method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110726443.9A CN113448648A (en) 2021-06-29 2021-06-29 Linux-compatible Android camera access method and device

Publications (1)

Publication Number Publication Date
CN113448648A true CN113448648A (en) 2021-09-28

Family

ID=77813909

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110726443.9A Pending CN113448648A (en) 2021-06-29 2021-06-29 Linux-compatible Android camera access method and device

Country Status (1)

Country Link
CN (1) CN113448648A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113891087A (en) * 2021-10-12 2022-01-04 深圳市算筹信息技术有限公司 A method and system for implementing virtualization hardware codec acceleration based on Linux system
CN114416292A (en) * 2021-12-31 2022-04-29 北京字节跳动网络技术有限公司 Virtualization method, device, apparatus, medium and product for serial port of positioning device
CN114449171A (en) * 2022-01-28 2022-05-06 青岛海信移动通信技术股份有限公司 Method for controlling camera, terminal device, storage medium and program product
CN115348386A (en) * 2022-07-13 2022-11-15 成都中科创达软件有限公司 USB camera management device, method, target system, device and storage medium
CN117176705A (en) * 2023-11-03 2023-12-05 成都阿加犀智能科技有限公司 Industrial camera video stream display method, device, equipment and medium
CN118660216A (en) * 2024-07-15 2024-09-17 广东保伦电子股份有限公司 USB camera information collection method, device, terminal equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102147725A (en) * 2011-03-29 2011-08-10 福州瑞芯微电子有限公司 Method for supporting dual cameras in Android
CN103559150A (en) * 2013-11-08 2014-02-05 深圳市道通科技有限公司 Realizing method and device for external camera of host, and mobile terminal
CN104394305A (en) * 2014-11-24 2015-03-04 上海盈方微电子有限公司 Compatibility method for supporting external mobile camera and built-in camera of mobile equipment in Android system
US20160044139A1 (en) * 2014-08-07 2016-02-11 Hsiu-Ping Lin Methods and systems for communications between apps and virtual machines
CN111475347A (en) * 2020-03-03 2020-07-31 福州瑞芯微电子股份有限公司 Method, device, equipment and medium for supporting hot plug and unplug function of camera
CN112612536A (en) * 2020-12-15 2021-04-06 麒麟软件有限公司 Method and device for controlling camera shooting based on Android application program in Linux system
CN112749022A (en) * 2019-10-29 2021-05-04 阿里巴巴集团控股有限公司 Camera resource access method, operating system, terminal and virtual camera

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102147725A (en) * 2011-03-29 2011-08-10 福州瑞芯微电子有限公司 Method for supporting dual cameras in Android
CN103559150A (en) * 2013-11-08 2014-02-05 深圳市道通科技有限公司 Realizing method and device for external camera of host, and mobile terminal
US20160044139A1 (en) * 2014-08-07 2016-02-11 Hsiu-Ping Lin Methods and systems for communications between apps and virtual machines
CN104394305A (en) * 2014-11-24 2015-03-04 上海盈方微电子有限公司 Compatibility method for supporting external mobile camera and built-in camera of mobile equipment in Android system
CN112749022A (en) * 2019-10-29 2021-05-04 阿里巴巴集团控股有限公司 Camera resource access method, operating system, terminal and virtual camera
CN111475347A (en) * 2020-03-03 2020-07-31 福州瑞芯微电子股份有限公司 Method, device, equipment and medium for supporting hot plug and unplug function of camera
CN112612536A (en) * 2020-12-15 2021-04-06 麒麟软件有限公司 Method and device for controlling camera shooting based on Android application program in Linux system

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113891087A (en) * 2021-10-12 2022-01-04 深圳市算筹信息技术有限公司 A method and system for implementing virtualization hardware codec acceleration based on Linux system
CN114416292A (en) * 2021-12-31 2022-04-29 北京字节跳动网络技术有限公司 Virtualization method, device, apparatus, medium and product for serial port of positioning device
CN114416292B (en) * 2021-12-31 2024-05-28 北京字节跳动网络技术有限公司 Virtualization method, equipment, device, medium and product for serial port of positioning equipment
CN114449171A (en) * 2022-01-28 2022-05-06 青岛海信移动通信技术股份有限公司 Method for controlling camera, terminal device, storage medium and program product
CN114449171B (en) * 2022-01-28 2023-10-27 青岛海信移动通信技术有限公司 Method for controlling camera, terminal device, storage medium and program product
CN115348386A (en) * 2022-07-13 2022-11-15 成都中科创达软件有限公司 USB camera management device, method, target system, device and storage medium
CN117176705A (en) * 2023-11-03 2023-12-05 成都阿加犀智能科技有限公司 Industrial camera video stream display method, device, equipment and medium
CN117176705B (en) * 2023-11-03 2024-01-26 成都阿加犀智能科技有限公司 Industrial camera video stream display method, device, equipment and medium
CN118660216A (en) * 2024-07-15 2024-09-17 广东保伦电子股份有限公司 USB camera information collection method, device, terminal equipment and storage medium

Similar Documents

Publication Publication Date Title
CN113448648A (en) Linux-compatible Android camera access method and device
EP3885903B1 (en) Cloud desktop upgrade method, cloud server, and storage medium
US20200409732A1 (en) Sharing multimedia physical functions in a virtualized environment on a processing unit
JP5026509B2 (en) Converting a machine to a virtual machine
US8448165B1 (en) System and method for logging operations of virtual machines
US8458694B2 (en) Hypervisor with cloning-awareness notifications
US8397242B1 (en) System and method for managing operations within virtual machines
CN100570563C (en) Manage computer memory in a computing environment with dynamic logical partitions
US20050132367A1 (en) Method, apparatus and system for proxying, aggregating and optimizing virtual machine information for network-based management
EP3879752B1 (en) Data processing method and apparatus, and server
JP2008503015A (en) Sharing a single physical device with multiple clients
CN113342422A (en) Linux-compatible Android multi-application camera access method and device
JP2010257430A (en) Computer and access control method
US9582444B1 (en) Selective partition based redirection for multi-partitioned USB devices
US11635970B2 (en) Integrated network boot operating system installation leveraging hyperconverged storage
JP6142527B2 (en) Setting information management program, information processing apparatus, and setting information management method
CN107026875A (en) The fusion method and device of multiple virtual desktop frameworks
US20140082275A1 (en) Server, host and method for reading base image through storage area network
CN104517067B (en) Access the method, apparatus and system of data
US8838913B1 (en) System and method for locating a memory page in a guest virtual machine
JP2007323354A (en) Machine management system
JP2009064303A (en) Imaging apparatus, shared resource management method, and program
WO2024067479A1 (en) Container escape detection method, electronic device, and system
CN114662103B (en) A file processing method, device and storage medium
WO2021118117A1 (en) Cloud server and operating method of the same

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination