[go: up one dir, main page]

CN115391063A - Video capture method, device, electronic device and readable storage medium - Google Patents

Video capture method, device, electronic device and readable storage medium Download PDF

Info

Publication number
CN115391063A
CN115391063A CN202211042581.6A CN202211042581A CN115391063A CN 115391063 A CN115391063 A CN 115391063A CN 202211042581 A CN202211042581 A CN 202211042581A CN 115391063 A CN115391063 A CN 115391063A
Authority
CN
China
Prior art keywords
interface
target
access request
candidate
access
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
CN202211042581.6A
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.)
Yuanxin Information Technology Group Co ltd
Original Assignee
Yuanxin Information Technology Group 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 Yuanxin Information Technology Group Co ltd filed Critical Yuanxin Information Technology Group Co ltd
Priority to CN202211042581.6A priority Critical patent/CN115391063A/en
Publication of CN115391063A publication Critical patent/CN115391063A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/76Adapting program code to run in a different environment; Porting

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application provides a video acquisition method and device, electronic equipment and a readable storage medium, and relates to the technical field of data processing. The method comprises the following steps: executing a target program in the first operating system, wherein the target program is developed based on the second operating system; the first terminal runs a first operating system; receiving a first access request sent by a target program, wherein the first access request is used for indicating that video equipment is accessed through a first target interface, and the first target interface is an interface based on a second operating system; and updating the first access request into a second access request, wherein the second access request is used for indicating that the video equipment is accessed through a second target interface, the second target interface is an interface based on the first operating system, and a first target access result which can be processed by a target program is obtained according to the second access request. According to the method and the device, the purpose that the target program can access the video equipment of the first terminal without modifying the function and the flow defined by the original video equipment accessed by the target program is achieved, and the change of transplantation is small.

Description

视频采集方法、装置、电子设备及可读存储介质Video capture method, device, electronic device and readable storage medium

技术领域technical field

本申请涉及数据处理技术领域,具体而言,本申请涉及一种视频采集方法、装置、电子设备及可读存储介质。The present application relates to the technical field of data processing, and in particular, the present application relates to a video collection method, device, electronic equipment and readable storage medium.

背景技术Background technique

V4l2(Video for linux2)称作linux视频设备驱动,是linux操作系统上实现视频采集的通用框架。现在绝大多数开源程序,例如webrtc、opencv等,在设计之初一般默认其对摄像头等视频设备的访问都是通过V4l2驱动对应的V4l2接口。V4l2 (Video for linux2) is called the linux video device driver, which is a general framework for realizing video capture on the linux operating system. At present, most open source programs, such as webrtc, opencv, etc., generally default to accessing video devices such as cameras through the V4l2 interface corresponding to the V4l2 driver at the beginning of the design.

但是,目前一些操作系统并不支持V4l2接口,这些操作系统各自都提供一套独有的本地接口供程序访问视频设备。当把支持V4l2接口的程序移植到这些不支持V4l2接口的操作系统上时,这些程序访问视频设备都需要和本地接口进行适配,此类适配的过程一般需要将该程序定义的访问视频设备和处理视频数据的相关接口函数修改为对应的本地接口函数。However, some operating systems do not support the V4l2 interface at present, and each of these operating systems provides a set of unique local interfaces for programs to access video devices. When transplanting programs that support the V4l2 interface to these operating systems that do not support the V4l2 interface, these programs need to adapt to the local interface when accessing video devices. The relevant interface functions for processing video data are modified to the corresponding local interface functions.

每个程序对视频设备的访问,定义的接口函数和程序流程基本都是不同的,这就导致每移植一个新的程序到不支持V4l2接口的操作系统时,该新的程序几乎都需要重复进行这种适配,工作量大且繁琐。Each program's access to the video device, the defined interface functions and program flow are basically different, which leads to the fact that every time a new program is transplanted to an operating system that does not support the V4l2 interface, the new program almost needs to be repeated This kind of adaptation requires a lot of work and is cumbersome.

发明内容Contents of the invention

本申请实施例提供了一种视频采集方法、装置、电子设备、计算机可读存储介质及计算机程序产品,用于解决开源程序几乎都需要重复进行对视频设备的访问的适配工作,工作量大且繁琐的技术问题。The embodiment of the present application provides a video acquisition method, device, electronic equipment, computer-readable storage medium, and computer program products, which are used to solve the adaptation work that almost all open source programs need to repeatedly access video equipment, and the workload is heavy. And cumbersome technical issues.

根据本申请实施例的第一方面,提供了一种视频采集方法,该方法包括:According to the first aspect of the embodiments of the present application, a video capture method is provided, the method comprising:

在第一操作系统中执行目标程序,目标程序基于第二终操作系统开发;executing the target program in the first operating system, the target program is developed based on the second terminal operating system;

接收目标程序发送的第一访问请求,第一访问请求用于指示通过第一目标接口访问视频设备,第一目标接口为基于第二操作系统的接口;receiving a first access request sent by the target program, where the first access request is used to indicate access to the video device through the first target interface, where the first target interface is an interface based on the second operating system;

将第一访问请求更新为第二访问请求,第二访问请求用于指示通过第二目标接口访问视频设备,第二目标接口为基于第一操作系统的接口;updating the first access request to a second access request, where the second access request is used to indicate access to the video device through a second target interface, where the second target interface is an interface based on the first operating system;

根据第二访问请求获得目标程序可处理的第一目标访问结果。A first target access result that can be processed by the target program is obtained according to the second access request.

在一个可能的实现方式中,将第一访问请求更新为第二访问请求,包括:In a possible implementation manner, updating the first access request to the second access request includes:

对第一访问请求进行解析,得到第一目标接口的标识和第一目标参数;第一目标参数是第一目标接口对应的接口函数可处理的参数;Analyzing the first access request to obtain an identifier of the first target interface and a first target parameter; the first target parameter is a parameter that can be processed by an interface function corresponding to the first target interface;

将第一目标接口函数的标识转换为第二目标接口函数的标识;converting the identification of the first target interface function to the identification of the second target interface function;

将第一目标参数转换为第二目标参数,第二目标参数是第二目标接口对应的接口函数可处理的参数;converting the first target parameter into a second target parameter, where the second target parameter is a parameter that can be processed by an interface function corresponding to the second target interface;

将第二目标接口函数的标识和第二目标参数进行封装,得到第二访问请求。Encapsulating the identifier of the second target interface function and the second target parameter to obtain a second access request.

在一个可能的实现方式中,根据第二访问请求获得目标程序可处理的第一目标访问结果,包括:In a possible implementation manner, obtaining the first target access result processable by the target program according to the second access request includes:

根据第二访问请求中的第二目标接口的标识,调用第二目标接口对应的接口函数对第二目标参数进行处理,得到第一处理结果;According to the identification of the second target interface in the second access request, call the interface function corresponding to the second target interface to process the second target parameter, and obtain the first processing result;

将第一处理结果转换为第二处理结果;transforming the first processing result into a second processing result;

将第二处理结果作为目标程序可处理的第一目标访问结果。The second processing result is used as the first target access result that can be processed by the target program.

在一个可能的实现方式中,将第一目标接口的标识转换为第二目标接口的标识,包括:In a possible implementation manner, converting the identifier of the first target interface into the identifier of the second target interface includes:

根据预先建立的第一映射关系,确定与第一目标接口的标识对应的第二目标接口的标识;Determine the identifier of the second target interface corresponding to the identifier of the first target interface according to the pre-established first mapping relationship;

第一映射关系为第一候选接口的标识和与第一候选接口的访问类型相同或相近的第二候选接口的标识之间的映射关系;第一候选接口和第二候选接口基于不同的操作系统;The first mapping relationship is the mapping relationship between the identifier of the first candidate interface and the identifier of the second candidate interface that has the same or similar access type as the first candidate interface; the first candidate interface and the second candidate interface are based on different operating systems ;

将第一目标参数转换为第二目标参数,包括:Convert the first target parameter to the second target parameter, including:

根据预先建立的第二映射关系,确定第一目标参数对应的第二目标参数;determining a second target parameter corresponding to the first target parameter according to a pre-established second mapping relationship;

第二映射关系为第一候选接口对应的接口函数可处理的第一候选参数和相应的访问类型相同或相近的第二候选接口对应的接口函数可处理的、与第一候选参数含义相同或相近的第二候选参数之间的映射关系。The second mapping relationship is the first candidate parameter that can be processed by the interface function corresponding to the first candidate interface and the corresponding access type that is the same or similar to the interface function corresponding to the second candidate interface that can be processed and has the same or similar meaning as the first candidate parameter The mapping relationship between the second candidate parameters of .

在一个可能的实现方式中,将第一处理结果转换为第二处理结果,包括:In a possible implementation manner, converting the first processing result into the second processing result includes:

根据预先建立的第三映射关系,确定第一处理结果对应的第二处理结果;determining a second processing result corresponding to the first processing result according to a pre-established third mapping relationship;

第三映射关系为第一候选结果和第二候选结果之间的映射关系;The third mapping relationship is a mapping relationship between the first candidate result and the second candidate result;

第一候选结果为调用第一候选接口的接口函数对第一候选参数进行处理得到的结果;第二候选结果为调用与第一候选接口的访问类型相同或相近的第二候选接口的接口函数对与第一候选参数存在第二映射关系的第二候选参数进行处理得到的结果。The first candidate result is the result obtained by calling the interface function of the first candidate interface to process the first candidate parameter; the second candidate result is the call of the interface function pair of the second candidate interface with the same or similar access type as the first candidate interface A result obtained by processing a second candidate parameter that has a second mapping relationship with the first candidate parameter.

在一个可能的实现方式中,第一访问请求或第二访问请求包括以下至少一种访问类型:In a possible implementation, the first access request or the second access request includes at least one of the following access types:

打开类型;启动预览类型;获取图像类型;停止预览类型;关闭类型;Open type; Start preview type; Get image type; Stop preview type; Close type;

其中,打开类型用于指示打开视频设备;Among them, the open type is used to indicate to open the video device;

启动预览类型用于指示预览视频设备采集的视频帧图像;The startup preview type is used to indicate the video frame image captured by the preview video device;

获取图像类型用于指示从缓冲区获取视频设备采集的视频帧图像;The acquired image type is used to indicate to obtain the video frame image captured by the video device from the buffer;

停止预览类型用于指示停止预览视频设备采集的视频帧图像;The stop preview type is used to indicate to stop previewing the video frame image collected by the video device;

关闭类型用于指示关闭视频设备。The shutdown type is used to indicate that the video device is turned off.

在一个可能的实现方式中,若第一访问请求的访问类型为启动预览类型,则调用第二目标接口对应的接口函数对第二目标参数进行处理之前,还包括In a possible implementation, if the access type of the first access request is the startup preview type, before calling the interface function corresponding to the second target interface to process the second target parameter, further include

注册帧回调函数;帧回调函数用于指示接收从视频设备采集的视频帧图像;Register the frame callback function; the frame callback function is used to indicate the reception of the video frame image collected from the video device;

运行帧回调函数,从视频设备获取视频帧图像,并将视频帧图像存储于缓冲区;缓冲区包括环形队列。Run the frame callback function to obtain the video frame image from the video device, and store the video frame image in the buffer; the buffer includes a circular queue.

根据本申请实施例的第二方面,提供了一种视频采集装置,该装置包括:According to the second aspect of the embodiments of the present application, a video acquisition device is provided, the device includes:

执行模块,用于在第一操作系统中执行目标程序,目标程序基于第二操作系统开发;The execution module is used to execute the target program in the first operating system, and the target program is developed based on the second operating system;

接收模块,用于接收目标程序发送的第一访问请求,第一访问请求用于指示通过第一目标接口访问视频设备,第一目标接口为基于第二操作系统的接口;The receiving module is configured to receive a first access request sent by the target program, the first access request is used to indicate access to the video device through the first target interface, and the first target interface is an interface based on the second operating system;

更新模块,用于将第一访问请求更新为第二访问请求,第二访问请求用于指示通过第二目标接口访问视频设备,第二目标接口为基于第一操作系统的接口;An update module, configured to update the first access request to a second access request, where the second access request is used to indicate access to the video device through a second target interface, where the second target interface is an interface based on the first operating system;

访问结果获得模块,用于根据第二访问请求获得目标程序可处理的第一目标访问结果。An access result obtaining module, configured to obtain a first target access result that can be processed by the target program according to the second access request.

根据本申请实施例的第三方面,提供了一种电子设备,该电子设备包括存储器、处理器及存储在存储器上的计算机程序,处理器执行程序时实现如第一方面所提供的方法的步骤。According to a third aspect of the embodiments of the present application, an electronic device is provided, the electronic device includes a memory, a processor, and a computer program stored on the memory, and the processor implements the steps of the method provided in the first aspect when executing the program .

根据本申请实施例的第四方面,提供了一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如第一方面所提供的方法的步骤。According to a fourth aspect of the embodiments of the present application, there is provided a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method provided in the first aspect are implemented.

根据本申请实施例的第五方面,提供了一种计算机程序产品,该计算机程序产品包括计算机指令,该计算机指令存储在计算机可读存储介质中,当计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行实现如第一方面所提供的方法的步骤。According to a fifth aspect of the embodiments of the present application, a computer program product is provided, the computer program product includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The computer instruction is read, and the processor executes the computer instruction, so that the computer device executes the steps for realizing the method provided in the first aspect.

本申请实施例提供的技术方案带来的有益效果是:在第一操作系统中执行目标程序,目标程序基于第二操作系统开发;接收目标程序发送的第一访问请求,第一访问请求用于指示通过第一目标接口访问视频设备,第一目标接口为基于第二操作系统的接口;将第一访问请求更新为第二访问请求,第二访问请求用于指示通过第二目标接口访问视频设备,第二目标接口为基于第一操作系统的接口;根据第二访问请求获得目标程序可处理的第一目标访问结果。本申请实施例无需修改目标程序原有的访问视频设备所定义的函数和流程即可实现目标程序访问视频设备,使得目标程序可以平滑移植到第一操作系统,移植的改动较小,提高了移植的效率,降低了移植的难度。The beneficial effects of the technical solution provided by the embodiment of the present application are: execute the target program in the first operating system, and the target program is developed based on the second operating system; receive the first access request sent by the target program, and the first access request is used for Indicate access to the video device through the first target interface, the first target interface is an interface based on the second operating system; update the first access request to the second access request, and the second access request is used to indicate access to the video device through the second target interface , the second target interface is an interface based on the first operating system; a first target access result that can be processed by the target program is obtained according to the second access request. The embodiments of the present application can realize the target program accessing the video device without modifying the functions and processes defined by the target program's original access to the video device, so that the target program can be smoothly transplanted to the first operating system, and the transplantation changes are small, which improves the transplantation process. The efficiency reduces the difficulty of transplantation.

附图说明Description of drawings

为了更清楚地说明本申请实施例中的技术方案,下面将对本申请实施例描述中所需要使用的附图作简单地介绍。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings that need to be used in the description of the embodiments of the present application.

图1为本申请实施例提供的一种视频采集方法的流程示意图;FIG. 1 is a schematic flow diagram of a video acquisition method provided in an embodiment of the present application;

图2为本申请实施例提供的通过一个环形队列来同步协调生产者线程和消费者线程的写入和读取的示意图;FIG. 2 is a schematic diagram of synchronously coordinating writing and reading of producer threads and consumer threads through a circular queue provided by the embodiment of the present application;

图3为本申请实施例提供的一种视频采集装置的结构示意图;FIG. 3 is a schematic structural diagram of a video acquisition device provided in an embodiment of the present application;

图4为本申请实施例提供的一种电子设备的结构示意图。FIG. 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.

具体实施方式Detailed ways

下面结合本申请中的附图描述本申请的实施例。应理解,下面结合附图所阐述的实施方式,是用于解释本申请实施例的技术方案的示例性描述,对本申请实施例的技术方案不构成限制。Embodiments of the present application are described below with reference to the drawings in the present application. It should be understood that the implementation manner described below in conjunction with the accompanying drawings is an exemplary description for explaining the technical solutions of the embodiments of the present application, and does not limit the technical solutions of the embodiments of the present application.

本技术领域技术人员可以理解,除非特意声明,这里使用的单数形式“一”、“一个”、“所述”和“该”也可包括复数形式。应该进一步理解的是,本申请实施例所使用的术语“包括”以及“包含”是指相应特征可以实现为所呈现的特征、信息、数据、步骤、操作、元件和/或组件,但不排除实现为本技术领域所支持其他特征、信息、数据、步骤、操作、元件、组件和/或它们的组合等。应该理解,当我们称一个元件被“连接”或“耦接”到另一元件时,该一个元件可以直接连接或耦接到另一元件,也可以指该一个元件和另一元件通过中间元件建立连接关系。此外,这里使用的“连接”或“耦接”可以包括无线连接或无线耦接。这里使用的术语“和/或”指示该术语所限定的项目中的至少一个,例如“A和/或B”可以实现为“A”,或者实现为“B”,或者实现为“A和B”。Those skilled in the art will understand that unless otherwise stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the terms "comprising" and "comprising" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and/or components, but do not exclude The realization is other features, information, data, steps, operations, elements, components and/or their combinations etc. supported by the technical field. It should be understood that when we say that an element is "connected" or "coupled" to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and another element pass through intermediate elements. Establish a connection relationship. Additionally, "connected" or "coupled" as used herein may include wireless connection or wireless coupling. The term "and/or" used herein indicates at least one of the items defined by the term, for example, "A and/or B" can be implemented as "A", or as "B", or as "A and B ".

为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the purpose, technical solution and advantages of the present application clearer, the implementation manners of the present application will be further described in detail below in conjunction with the accompanying drawings.

下面对本申请涉及的术语及相关技术进行说明:The terms and related technologies involved in this application are described below:

V4L2是Video4linux2的简称,为linux中关于视频设备的内核驱动,包括视频输入(如摄像头采集视频数据)、视频输出(如VGA输出等)以及视频编解码等数据流管理功能。V4L2 is the abbreviation of Video4linux2, which is the kernel driver of video equipment in linux, including video input (such as camera collecting video data), video output (such as VGA output, etc.) and data stream management functions such as video codec.

下面通过对几个示例性实施方式的描述,对本申请实施例的技术方案以及本申请的技术方案产生的技术效果进行说明。需要指出的是,下述实施方式之间可以相互参考、借鉴或结合,对于不同实施方式中相同的术语、相似的特征以及相似的实施步骤等,不再重复描述。The following describes the technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application by describing several exemplary implementations. It should be pointed out that the following embodiments may refer to, learn from or combine with each other, and the same terms, similar features, and similar implementation steps in different embodiments will not be described repeatedly.

本申请实施例中提供了一种视频采集的方法,如图1所示,该方法包括:A method of video acquisition is provided in the embodiment of the present application, as shown in Figure 1, the method includes:

步骤S101,在第一操作系统中执行目标程序,目标程序基于第二操作系统开发。Step S101, execute the target program in the first operating system, and the target program is developed based on the second operating system.

本申请实施例第一操作系统是不支持v4l2驱动的操作系统,例如一些国产操作系统,第一操作系统提供一套独有的本地接口供应用程序访问视频设备。In the embodiment of the present application, the first operating system is an operating system that does not support the v4l2 driver, such as some domestic operating systems. The first operating system provides a set of unique local interfaces for applications to access video devices.

本申请实施例第二操作系统是支持v4l2驱动的操作系统,例如linux操作系统,在第二操作系统编译的程序通过v4l2驱动对应的v4l2接口访问视频设备。In the embodiment of the present application, the second operating system is an operating system that supports the v4l2 driver, such as the linux operating system, and the program compiled in the second operating system accesses the video device through the v4l2 interface corresponding to the v4l2 driver.

本申请实施例目标程序可以是对视频设备有访问需求的任意程序,例如webrtc、opencv程序等开源程序,也可以是常见的相机应用程序、视频应用程序等。该视频设备可以是任意的可以采集视频的设备,例如摄像头。The target program in this embodiment of the present application may be any program that requires access to video equipment, such as open source programs such as webrtc and opencv programs, or common camera application programs, video application programs, and the like. The video device may be any device capable of collecting video, such as a camera.

由于目标程序是基于第二操作系统开发的,在第二操作系统编译的程序通过v4l2驱动对应的v4l2接口访问视频设备,因此目标程序通过v4l2接口访问视频设备。Since the target program is developed based on the second operating system, the program compiled in the second operating system accesses the video device through the v4l2 interface corresponding to the v4l2 driver, so the target program accesses the video device through the v4l2 interface.

本申请实施例发生于目标程序由第二操作系统移植至第一操作系统之后,在第一操作系统中执行该目标程序。In the embodiment of the present application, after the target program is transplanted from the second operating system to the first operating system, the target program is executed in the first operating system.

步骤S102,接收目标程序发送的第一访问请求,第一访问请求用于指示通过第一目标接口访问视频设备,第一目标接口为基于第二操作系统的接口。Step S102, receiving a first access request sent by the target program, the first access request is used to instruct to access the video device through the first target interface, and the first target interface is an interface based on the second operating system.

本申请实施例目标程序在需要访问视频设备时,会发送第一访问请求,第一访问请求用于指示通过第一目标接口访问视频设备,第一目标接口为基于第二操作系统的接口,即第一目标接口属于v4l2接口,目标程序意图通过第一目标接口来访问运行第二操作系统的终端中的视频设备。When the target program in the embodiment of the present application needs to access the video device, it will send a first access request. The first access request is used to indicate access to the video device through the first target interface. The first target interface is an interface based on the second operating system, that is, The first target interface belongs to the v4l2 interface, and the target program intends to access the video device in the terminal running the second operating system through the first target interface.

步骤S103,将第一访问请求更新为第二访问请求,第二访问请求用于指示通过第二目标接口访问视频设备,第二目标接口为基于第一操作系统的接口,即第一操作系统提供的一套访问视频设备的接口,这套接口一般是第一操作系统独有的,有时也称为本地接口。Step S103, update the first access request to a second access request, the second access request is used to indicate access to the video device through the second target interface, the second target interface is an interface based on the first operating system, that is, the first operating system provides A set of interfaces for accessing video devices. This set of interfaces is generally unique to the first operating system, and is sometimes called a local interface.

第一访问请求用于指示通过第一目标接口访问视频设备,然而目标程序是在第一操作系统中被执行,第一操作系统并不支持第一目标接口访问视频设备,因此目标程序在第一操作系统中被执行时无法直接通过第一目标接口访问视频设备。The first access request is used to indicate to access the video device through the first target interface, but the target program is executed in the first operating system, and the first operating system does not support the first target interface to access the video device, so the target program is in the first When the operating system is executed, it cannot directly access the video device through the first target interface.

本申请实施例在接收到第一访问请求后,将第一访问请求转换为第二访问请求,第二访问请求用于指示通过第二目标接口访问视频设备,第二目标接口为基于第一操作系统的接口,可通过第二目标接口访问视频设备,因此,需将第一访问请求更新为第二访问请求。In this embodiment of the present application, after receiving the first access request, the first access request is converted into a second access request, the second access request is used to indicate access to the video device through the second target interface, and the second target interface is based on the first operation The interface of the system can access the video device through the second target interface, therefore, it is necessary to update the first access request to the second access request.

步骤S104,根据第二访问请求获得目标程序可处理的第一目标访问结果。Step S104, obtaining the first target access result that can be processed by the target program according to the second access request.

由于第二访问请求指示通过第二目标接口访问视频设备,第一操作系统支持第二目标接口,因此,可先根据第二访问请求获得第一处理结果,第一操作系统可对第一处理结果进行后续处理,再将第一处理结果转换为第二处理结果,基于第二操作系统开发的目标程序后续可对第二处理结果进行后续处理,可将第二处理结果作为目标程序可处理的第一目标访问结果,使得目标程序后续可以对第一目标访问结果进行处理。Since the second access request indicates access to the video device through the second target interface, and the first operating system supports the second target interface, the first processing result can be obtained according to the second access request first, and the first operating system can process the first processing result Perform subsequent processing, and then convert the first processing result into a second processing result. The target program developed based on the second operating system can subsequently perform subsequent processing on the second processing result, and the second processing result can be used as the second processing result that the target program can process. A target access result, so that the target program can subsequently process the first target access result.

本申请实施例在第一操作系统中执行目标程序,目标程序基于第二操作系统开发;接收目标程序发送的第一访问请求,第一访问请求用于指示通过第一目标接口访问视频设备,第一目标接口为基于第二操作系统的接口;将第一访问请求更新为第二访问请求,第二访问请求用于指示通过第二目标接口访问视频设备,第二目标接口为基于第一操作系统的接口;根据第二访问请求获得目标程序可处理的第一目标访问结果。本申请实施例无需修改目标程序原有的访问视频设备所定义的函数和流程即可实现目标程序访问视频设备,使得目标程序可以平滑移植到第一操作系统,移植的改动较小,提高了移植的效率,降低了移植的难度。In the embodiment of the present application, the target program is executed in the first operating system, and the target program is developed based on the second operating system; the first access request sent by the target program is received, and the first access request is used to indicate access to the video device through the first target interface. A target interface is an interface based on the second operating system; the first access request is updated to a second access request, and the second access request is used to indicate access to the video device through the second target interface, and the second target interface is based on the first operating system an interface; obtaining a first target access result that can be processed by the target program according to the second access request. The embodiments of the present application can realize the target program accessing the video device without modifying the functions and processes defined by the target program's original access to the video device, so that the target program can be smoothly transplanted to the first operating system, and the transplantation changes are small, which improves the transplantation process. The efficiency reduces the difficulty of transplantation.

本申请实施例中提供了一种可能的实现方式,将第一访问请求更新为第二访问请求,包括:A possible implementation is provided in the embodiment of this application, updating the first access request to the second access request, including:

对第一访问请求进行解析,得到第一目标接口的标识和第一目标参数;第一目标参数是第一目标接口对应的接口函数可处理的参数;Analyzing the first access request to obtain an identifier of the first target interface and a first target parameter; the first target parameter is a parameter that can be processed by an interface function corresponding to the first target interface;

将第一目标接口的标识转换为第二目标接口的标识;converting the identification of the first target interface to the identification of the second target interface;

将第一目标参数转换为第二目标参数,第二目标参数是第二目标接口对应的接口函数可处理的参数;converting the first target parameter into a second target parameter, where the second target parameter is a parameter that can be processed by an interface function corresponding to the second target interface;

将第二目标接口的标识和第二目标参数进行封装,得到第二访问请求。Encapsulate the identifier of the second target interface and the second target parameter to obtain the second access request.

本申请实施例在将第一访问请求更新为第二访问请求的过程中,先对该第一访问请求进行解析,得到第一目标接口的标识和第一目标参数,根据第一目标接口的标识可确定第一目标接口;第一目标参数是第一目标接口对应的接口函数可处理的参数。In the embodiment of the present application, in the process of updating the first access request to the second access request, the first access request is first parsed to obtain the first target interface identifier and the first target parameter, and according to the first target interface identifier The first target interface may be determined; the first target parameter is a parameter that can be processed by an interface function corresponding to the first target interface.

本申请实施例可根据第一目标接口的标识和第一目标参数确定第一访问请求的访问类型,通常情况访问类型包括以下至少一种:打开类型、启动预览类型、获取图像类型、停止预览类型、关闭类型等。In this embodiment of the present application, the access type of the first access request can be determined according to the identifier of the first target interface and the first target parameter. Usually, the access type includes at least one of the following: open type, start preview type, acquire image type, stop preview type , shutdown type, etc.

其中,打开类型用于指示打开视频设备;启动预览类型用于指示预览视频设备采集的视频帧图像;获取图像类型用于指示获视频设备采集的视频帧图像;停止预览类型用于指示停止预览视频设备采集的视频帧图像;关闭类型用于指示关闭视频设备。Among them, the open type is used to indicate the opening of the video device; the start preview type is used to indicate the preview of the video frame image captured by the video device; the acquisition image type is used to indicate the video frame image captured by the video device; the stop preview type is used to indicate the stop of the video preview The video frame image captured by the device; the shutdown type is used to indicate that the video device is turned off.

目标程序通过v4l2接口访问视频设备,v4l2接口用来访问视频设备的核心接口有三个,分别是open接口、close接口以及ioctl接口,即第一目标接口可以是任意的上述v4l2接口。The target program accesses the video device through the v4l2 interface. There are three core interfaces used by the v4l2 interface to access the video device, namely the open interface, the close interface and the ioctl interface. That is, the first target interface can be any of the above-mentioned v4l2 interfaces.

其中,open接口为打开类型,用于指示打开视频设备,为实现打开视频设备需要调用open接口,open接口对应的接口函数的参数为字符串,如:“/dev/video1”、“/dev/video2”,参数“/dev/video1”表征打开第一个视频设备,“/dev/video2”表征打开第二视频设备;close接口为关闭类型,用于指示关闭视频设备,为实现关闭视频设备需要调用的close接口;ioctl接口可能属于启动预览类型,也可能属于获取图像类型,也可能属于停止预览类型,需进一步根据ioctl接口对应的接口函数可处理的参数来确定访问类型。具体的,若参数为是“VIDIOC_STREAMON”,表征启动预览类型,即预览视频设备采集的视频帧图像;若参数为是“VIDIOC_DQBUF”,表征获取图像类型,即获取视频设备采集的视频帧图像;若参数为是“VIDIOC_STREAMOFF”,表征停止预览类型,即停止预览视频设备采集的视频帧图像。Among them, the open interface is the open type, which is used to indicate the opening of the video device. In order to open the video device, the open interface needs to be called. The parameter of the interface function corresponding to the open interface is a string, such as: "/dev/video1", "/dev/ video2", the parameter "/dev/video1" indicates that the first video device is opened, and "/dev/video2" indicates that the second video device is opened; the close interface is a close type, used to indicate that the video device is closed, and it is necessary to close the video device The close interface to be called; the ioctl interface may belong to the type of starting preview, or the type of obtaining images, or the type of stopping preview. The access type needs to be further determined according to the parameters that can be processed by the interface function corresponding to the ioctl interface. Specifically, if the parameter is "VIDIOC_STREAMON", it indicates the start preview type, that is, to preview the video frame image collected by the video device; if the parameter is "VIDIOC_DQBUF", it indicates the type of image to be obtained, that is, to obtain the video frame image collected by the video device; if The parameter is "VIDIOC_STREAMOFF", which represents the stop preview type, that is, stop previewing the video frame image collected by the video device.

另外,v4l2接口还包括一些其他的辅助接口,例如select接口以及mmap接口等,select接口用于确定一个或多个套接字的状态,mmap接口用于指示将一个文件或者其它对象映射进内存。In addition, the v4l2 interface also includes some other auxiliary interfaces, such as the select interface and the mmap interface. The select interface is used to determine the status of one or more sockets, and the mmap interface is used to indicate that a file or other objects are mapped into memory.

本申请实施例在确定第一目标接口的标识和第一目标参数后,将第一目标接口的标识转换为第二目标接口的标识,将第一目标参数转换为第二目标参数,第二目标参数是第二目标接口对应的接口函数可处理的参数。In this embodiment of the present application, after determining the identifier of the first target interface and the first target parameter, the identifier of the first target interface is converted into the identifier of the second target interface, the first target parameter is converted into the second target parameter, and the second target The parameters are parameters that can be processed by the interface function corresponding to the second target interface.

具体而言,假设第一操作系统提供相机接口的功能模块是droidmedia,打开类型的接口为connect接口,其对应的接口函数为DroidMediaCamera*droid_media_camera_connect(intcamera_number)函数,该接口函数的参数相机的整型id。Specifically, it is assumed that the first operating system provides a camera interface function module is droidmedia, the open interface is a connect interface, and its corresponding interface function is DroidMediaCamera*droid_media_camera_connect (intcamera_number) function, the parameter of the interface function is the integer id of the camera .

若第一目标接口的标识是open接口的标识,第一目标参数是“/dev/video1”,则需将open接口的标识转换为相应的第二目标接口connect接口的标识,将第一目标参数“/dev/video1”转换为第二目标参数“1”。If the ID of the first target interface is the ID of the open interface, and the first target parameter is "/dev/video1", the ID of the open interface needs to be converted to the ID of the corresponding second target interface connect interface, and the first target parameter "/dev/video1" translates to the second target parameter "1".

第一操作系统提供的关闭类型的接口为disconnect接口,其对应的接口函数为void droid_media_camera_disconnect(DroidMediaCamera*camera),参数camera是打开视频设备时的返回值,为DroidMediaCamera指针类型。若第一目标接口函数的标识是close接口的标识,第一目标参数是打开视频设备时的返回值(该返回值可根据文件描述符fd查询),则需将第一目标接口close接口的标识转换为相应的第二目标接口disconnect接口的标识,通过fd查询打开视频设备时的返回值,将该返回值作为第一目标参数,并将该第一目标参数转换为相应的DroidMediaCamera指针类型的第二目标参数。The disconnect interface provided by the first operating system is a disconnect interface, and its corresponding interface function is void droid_media_camera_disconnect(DroidMediaCamera*camera), and the parameter camera is the return value when the video device is turned on, which is a pointer type of DroidMediaCamera. If the mark of the first target interface function is the mark of the close interface, and the first target parameter is the return value when opening the video equipment (this return value can be queried according to the file descriptor fd), then the mark of the first target interface close interface needs to be Convert to the identifier of the corresponding second target interface disconnect interface, query the return value when opening the video device through fd, use the return value as the first target parameter, and convert the first target parameter into the corresponding DroidMediaCamera pointer type Two target parameters.

第一操作系统启动预览类型的接口为start_preview,其对应的接口函数为booldroid_media_camera_start_preview(DroidMediaCamera*camera),在调用这个函数之前需要注册帧回调函数,用来接收从视频设备采集的图像,帧回调函数为:droid_media_camera_set_callbacks,注册帧回调函数的接口为帧回调接口。在帧回调函数的实现中,每收到一帧视频帧图像,获得该视频帧图像的地址和长度,把视频帧图像写入环形缓冲区,如:mRingBufQueue.push(frameData,dataLen)。The interface of the first operating system startup preview type is start_preview, and its corresponding interface function is booldroid_media_camera_start_preview(DroidMediaCamera*camera). Before calling this function, a frame callback function needs to be registered to receive images collected from video devices. The frame callback function is : droid_media_camera_set_callbacks, the interface for registering the frame callback function is the frame callback interface. In the implementation of the frame callback function, each time a video frame image is received, the address and length of the video frame image are obtained, and the video frame image is written into the ring buffer, such as: mRingBufQueue.push(frameData, dataLen).

第一操作系统中获取图像类型的接口为mRingBufQueue接口,其对应的接口函数为mRingBufQueue.pop(frameData,dataLen);停止预览类型的接口为stop_preview接口,其对应的接口函数为void droid_media_camera_stop_preview(DroidMediaCamera*camera),参数camera是打开视频设备时的返回值,可根据fd查询。The interface for obtaining the image type in the first operating system is the mRingBufQueue interface, and its corresponding interface function is mRingBufQueue.pop(frameData, dataLen); the interface for stopping the preview type is the stop_preview interface, and its corresponding interface function is void droid_media_camera_stop_preview(DroidMediaCamera*camera ), the parameter camera is the return value when the video device is turned on, and can be queried according to fd.

每个第一目标接口一般都有与该第一目标接口的访问类型相同或相近的第二目标接口,本申请实施例在将第一目标接口的标识转换为第二目标接口的标识,将第一目标参数转换为第二目标参数后,将第二目标接口的标识和第二目标参数进行封装,得到第二访问请求,通过该第二访问请求能够使得目标程序在第一操作系统中访问视频设备。Each first target interface generally has a second target interface with the same or similar access type as the first target interface. In this embodiment of the present application, the identification of the first target interface is converted into the identification of the second target interface, After a target parameter is converted into a second target parameter, the identifier of the second target interface and the second target parameter are encapsulated to obtain a second access request, through which the target program can access the video in the first operating system equipment.

本申请实施例中提供了一种可能的实现方式,根据第二访问请求获得目标程序可处理的第一目标访问结果,包括:A possible implementation is provided in the embodiment of this application. According to the second access request, the first target access result that can be processed by the target program is obtained, including:

根据第二访问请求中的第二目标接口的标识,确定第二目标接口,并调用第二目标接口对应的接口函数对第二目标参数进行处理,得到第一处理结果;Determine the second target interface according to the identifier of the second target interface in the second access request, and call an interface function corresponding to the second target interface to process the second target parameter to obtain a first processing result;

将第一处理结果转换为第二处理结果;transforming the first processing result into a second processing result;

将第二处理结果作为目标程序可处理的第一目标访问结果。The second processing result is used as the first target access result that can be processed by the target program.

本申请实施例第二访问请求中包括第二目标接口的标识和第二目标参数,可根据第二目标接口的标识确定第二目标接口,调用第二目标接口对应的接口函数对第二目标参数进行处理,得到第一处理结果,即本申请实施例实质上还是调用第二目标接口函数,并没有调用第一目标接口函数。In the embodiment of the present application, the second access request includes the identification of the second target interface and the second target parameter, the second target interface can be determined according to the identification of the second target interface, and the interface function corresponding to the second target interface is called to modify the second target parameter After processing, the first processing result is obtained, that is, the embodiment of the present application essentially still calls the second target interface function, and does not call the first target interface function.

本申请实施例第一操作系统后续可对第一处理结果进行处理,然由于目标程序是基于第二操作系统开发的,目标程序后续无法对第一处理结果进行处理,因此,还需将第一处理结果转换为第二处理结果,第二处理结果基于第二操作系统,目标程序后续才可对第二处理结果进行处理,将第二处理结果作为目标程序可处理的第一目标访问结果。In the embodiment of the present application, the first operating system can subsequently process the first processing result. However, since the target program is developed based on the second operating system, the target program cannot subsequently process the first processing result. Therefore, the first The processing result is converted into a second processing result, the second processing result is based on the second operating system, the target program can process the second processing result later, and the second processing result is used as the first target access result that the target program can process.

本申请实施例中提供了一种可能的实现方式,将第一目标接口的标识转换为第二目标接口的标识,包括:A possible implementation is provided in the embodiment of this application, converting the identifier of the first target interface into the identifier of the second target interface, including:

根据预先建立的第一映射关系,确定与第一目标接口的标识对应的第二目标接口的标识;Determine the identifier of the second target interface corresponding to the identifier of the first target interface according to the pre-established first mapping relationship;

第一映射关系为第一候选接口的标识和与第一候选接口的访问类型相同或相近的第二候选接口的标识之间的映射关系;第一候选接口和第二候选接口基于不同的操作系统。The first mapping relationship is the mapping relationship between the identifier of the first candidate interface and the identifier of the second candidate interface that has the same or similar access type as the first candidate interface; the first candidate interface and the second candidate interface are based on different operating systems .

本申请实施例建立了第一候选接口对应的接口的标识和与第一候选接口的访问类型相同或相近的第二候选接口的标识之间的第一映射关系,具体而言,例如建立了open接口(基于第一操作系统的接口)的标识和connect接口(基于第二操作系统的接口)之间的第一映射关系,二者的访问类型是相同的,都是打开类型,同样可建立其他访问类型的第一候选接口的标识和相应的第二候选接口的标识之间的第一映射关系,本申请实施例在此不再一一举例。The embodiment of the present application establishes the first mapping relationship between the identifier of the interface corresponding to the first candidate interface and the identifier of the second candidate interface whose access type is the same as or similar to that of the first candidate interface. Specifically, for example, the open The first mapping relationship between the identifier of the interface (the interface based on the first operating system) and the connect interface (the interface based on the second operating system), the access types of the two are the same, both are open types, and other The first mapping relationship between the identifiers of the first candidate interfaces of the access type and the identifiers of the corresponding second candidate interfaces will not be exemplified one by one in this embodiment of the present application.

将第一目标参数转换为第二目标参数,包括:Convert the first target parameter to the second target parameter, including:

根据预先建立的第二映射关系,确定第一目标参数对应的第二目标参数;determining a second target parameter corresponding to the first target parameter according to a pre-established second mapping relationship;

第二映射关系为第一候选接口对应的接口函数可处理的第一候选参数和相应的访问类型相同或相近的第二候选接口对应的接口函数可处理的、与第一候选参数含义相同或相近的第二候选参数之间的映射关系。The second mapping relationship is the first candidate parameter that can be processed by the interface function corresponding to the first candidate interface and the corresponding access type that is the same or similar to the interface function corresponding to the second candidate interface that can be processed and has the same or similar meaning as the first candidate parameter The mapping relationship between the second candidate parameters of .

本申请实施例除了建立第一映射关系,还建立了第一候选接口对应的接口函数可处理的第一候选参数和相应的访问类型相同或相近的第二候选接口对应的接口函数可处理的、与第一候选参数含义相同或相近的第二候选参数之间的映射关系,具体而言,假设第一候选接口为open接口,open接口对应的接口函数(即open函数)可处理的第一候选参数为“/dev/videoX”,其中,X为正整数,表征第X个视频设备;第一操作系统中与open函数的访问类型相同或相近的第二候选接口为connect接口,对应的接口函数为DroidMediaCamera*droid_media_camera_connect(intcamera_number),该第二候选接口对应的接口函数可处理的与第一候选参数“/dev/videoX”表达含义相同的第二候选参数为“X”,其中,X为正整数,表征第X个视频设备。In addition to establishing the first mapping relationship, the embodiment of the present application also establishes the first candidate parameters that can be processed by the interface function corresponding to the first candidate interface and the corresponding access types that can be processed by the interface function corresponding to the second candidate interface. The mapping relationship between the second candidate parameters that have the same or similar meaning as the first candidate parameter. Specifically, assuming that the first candidate interface is an open interface, the first candidate that can be processed by the interface function corresponding to the open interface (that is, the open function) The parameter is "/dev/videoX", where X is a positive integer representing the Xth video device; the second candidate interface in the first operating system that has the same or similar access type as the open function is the connect interface, and the corresponding interface function DroidMediaCamera*droid_media_camera_connect(intcamera_number), the second candidate parameter that the interface function corresponding to the second candidate interface can handle with the same meaning as the first candidate parameter "/dev/videoX" is "X", where X is a positive integer , representing the Xth video device.

本申请实施例中提供了一种可能的实现方式,将第一处理结果转换为第二处理结果,包括:A possible implementation is provided in the embodiment of this application, converting the first processing result into the second processing result, including:

根据预先建立的第三映射关系,确定第一处理结果对应的第二处理结果;determining a second processing result corresponding to the first processing result according to a pre-established third mapping relationship;

第三映射关系为第一候选结果和第二候选结果之间的映射关系;The third mapping relationship is a mapping relationship between the first candidate result and the second candidate result;

第一候选结果为调用第一候选接口的接口函数对第一候选参数进行处理得到的结果;第二候选结果为调用与第一候选接口函的访问类型相同或相近的第二候选接口的接口函数对与第一候选参数存在第二映射关系的第二候选参数进行处理得到的结果。The first candidate result is the result obtained by calling the interface function of the first candidate interface to process the first candidate parameter; the second candidate result is the call of the interface function of the second candidate interface whose access type is the same as or similar to that of the first candidate interface function A result obtained by processing a second candidate parameter that has a second mapping relationship with the first candidate parameter.

本申请实施例还建立了第三映射关系,第三映射关系为第一候选结果和第二候选结果之间的映射关系;第一候选结果为调用第一候选接口对应的接口函数对第一候选参数进行处理得到的结果。The embodiment of the present application also establishes a third mapping relationship, the third mapping relationship is the mapping relationship between the first candidate result and the second candidate result; the first candidate result is the call of the interface function corresponding to the first candidate interface to the first candidate The result obtained by processing the parameters.

本申请实施例将第一处理结果转换为第二处理结果,具体的,可根据预先建立的第三映射关系,确定第一处理结果对应的第二处理结果。In this embodiment of the present application, the first processing result is converted into the second processing result. Specifically, the second processing result corresponding to the first processing result may be determined according to a pre-established third mapping relationship.

本申请实施例中提供了一种可能的实现方式,第一访问请求或第二访问请求包括以下至少一种访问类型:打开类型;启动预览类型;获取图像类型;停止预览类型;关闭类型。An embodiment of the present application provides a possible implementation manner, where the first access request or the second access request includes at least one of the following access types: open type; start preview type; acquire image type; stop preview type; close type.

其中,打开类型用于指示打开视频设备;Among them, the open type is used to indicate to open the video device;

启动预览类型用于预览视频设备采集的视频帧图像;The startup preview type is used to preview the video frame image collected by the video device;

获取图像类型用于指示获取视频设备采集的视频帧图像;The acquired image type is used to indicate the acquired video frame image captured by the video device;

停止预览类型用于指示停止预览视频设备采集的视频帧图像;The stop preview type is used to indicate to stop previewing the video frame image collected by the video device;

关闭类型用于指示关闭视频设备。The shutdown type is used to indicate that the video device is turned off.

在前述实施例中已经对各访问类型进行解释,本申请实施例在此不再进行赘述。Each access type has been explained in the preceding embodiments, and details will not be repeated here in this embodiment of the present application.

本申请实施例中提供了一种可能的实现方式,若第一访问请求的访问类型为启动预览类型,则调用第二目标接口对应的接口函数对第二目标参数进行处理之前,还包括:A possible implementation is provided in the embodiment of the present application. If the access type of the first access request is the startup preview type, before calling the interface function corresponding to the second target interface to process the second target parameter, it also includes:

注册帧回调函数;帧回调函数用于指示接收从视频设备采集的视频帧图像;Register the frame callback function; the frame callback function is used to indicate the reception of the video frame image collected from the video device;

运行帧回调函数,从视频设备获取视频帧图像,并将视频帧图像存储于缓冲区;缓冲区包括环形队列。Run the frame callback function to obtain the video frame image from the video device, and store the video frame image in the buffer; the buffer includes a circular queue.

本申请实施例对于第一操作系统而言,在调用启动预览类型对应的接口函数之前,还可以注册帧回调函数,帧回调函数用于指示接收从视频设备采集的视频帧图像。在运行该帧回调函数时,会从视频设备获取视频帧图像,获取每帧视频帧图像的地址和长度,将每帧视频帧图像写入缓冲区,该缓冲区可以为环形队列,环形队列可以保证无阻塞,实现写入无需等待从而保证写入的实时性。In the embodiment of the present application, for the first operating system, before invoking the interface function corresponding to the startup preview type, a frame callback function may also be registered, and the frame callback function is used to indicate to receive a video frame image collected from a video device. When running the frame callback function, the video frame image will be obtained from the video device, the address and length of each video frame image will be obtained, and each frame of video frame image will be written into the buffer. The buffer can be a ring queue, and the ring queue can be Guaranteed non-blocking, realizes writing without waiting to ensure real-time writing.

视频帧图像或视频数据流来自基于第一操作系统的第一候选接口,通常在启动预览后,通过帧回调函数以一定的帧率将视频帧图像发送给访问该第一候选接口的程序,本申请实施例目标程序是基于第二操作系统开发的,目标程序无法直接注册帧回调函数,因此,在启动预览时,在第一操作系统中由第一操作系统自身或相关程序为目标程序注册帧回调函数。The video frame image or video data stream comes from the first candidate interface based on the first operating system. Usually, after the preview is started, the video frame image is sent to the program accessing the first candidate interface at a certain frame rate through the frame callback function. The target program in the embodiment of the application is developed based on the second operating system, and the target program cannot directly register the frame callback function. Therefore, when starting the preview, the first operating system itself or a related program registers the frame for the target program in the first operating system Callback.

视频帧图像的写入和读取由两个不同的线程执行,生产者线程将视频帧图像写入缓冲区,该缓冲区可以是环形队列,生产者线程是视频帧图像的提供者,即第一候选接口是提供者;消费者线程从缓冲区中读取视频帧图像,消费者线程是使用视频帧图像的消费者,即目标程序是消费者The writing and reading of video frame images are performed by two different threads. The producer thread writes the video frame images into the buffer, which can be a circular queue. The producer thread is the provider of the video frame images, that is, the first A candidate interface is the provider; the consumer thread reads the video frame image from the buffer, and the consumer thread is the consumer that uses the video frame image, that is, the target program is the consumer

如图2所示,其示例性示出了通过一个环形队列来同步协调生产者线程和消费者线程的写入和读取的示意图,生产者线程不断的第一候选接口获得视频帧图像,将视频帧图像作为视频数据写入环形队列;而消费者线程在需要时将视频数据读出。in和out是环形队列的缓冲区索引,in是写入缓冲区的索引,out是读出缓冲区的索引,当两者相等时,环形队列为空,还没有视频数据被写入,初始化阶段将两者设置为相等。As shown in Figure 2, it exemplarily shows a schematic diagram of synchronously coordinating the writing and reading of the producer thread and the consumer thread through a circular queue, the producer thread continuously obtains the video frame image through the first candidate interface, and the Video frame images are written to the circular queue as video data; and consumer threads read video data out when needed. in and out are the buffer indexes of the ring queue, in is the index of the write buffer, and out is the index of the read buffer. When the two are equal, the ring queue is empty and no video data has been written. The initialization phase Set both to be equal.

当生产者线程写入一帧数据后,索引in加1,生产者无需关心消费者是否读出或什么时候读出,它可以不断的写入视频数据,索引in的变化如下:After the producer thread writes a frame of data, the index in is incremented by 1. The producer does not need to care whether or when the consumer reads out. It can continuously write video data. The changes in the index in are as follows:

Figure BDA0003820971580000141
Figure BDA0003820971580000141

消费者线程在需要时读出数据,索引out加1。如果读入时发现in与out相等,消费者线程需要等待,直到有新视频数据写入时再继续读入。The consumer thread reads the data when needed, and the index out is incremented by 1. If it is found that in and out are equal when reading, the consumer thread needs to wait until new video data is written before continuing to read.

本申请实施例提供了一种视频采集装置,应用于第一终端,第一终端运行第一操作系统,如图3所示,该视频采集装置30可以包括:An embodiment of the present application provides a video capture device, which is applied to a first terminal, and the first terminal runs a first operating system. As shown in FIG. 3 , the video capture device 30 may include:

执行模块310,用于在第一操作系统中执行目标程序,目标程序基于第二操作系统开发;An execution module 310, configured to execute the target program in the first operating system, where the target program is developed based on the second operating system;

接收模块320,用于接收目标程序发送的第一访问请求,第一访问请求用于指示通过第一目标接口访问视频设备,第一目标接口为基于第二操作系统的接口;The receiving module 320 is configured to receive a first access request sent by the target program, the first access request is used to indicate access to the video device through the first target interface, and the first target interface is an interface based on the second operating system;

更新模块330,用于将第一访问请求更新为第二访问请求,第二访问请求用于指示通过第二目标接口访问视频设备,第二目标接口为基于第一操作系统的接口;An update module 330, configured to update the first access request to a second access request, where the second access request is used to indicate access to the video device through a second target interface, where the second target interface is an interface based on the first operating system;

访问结果获得模块340,用于根据第二访问请求获得目标程序可处理的第一目标访问结果。An access result obtaining module 340, configured to obtain a first target access result that can be processed by the target program according to the second access request.

本申请实施例通过在第一操作系统中执行目标程序,目标程序基于第二操作系统开发;接收目标程序发送的第一访问请求,第一访问请求用于指示通过第一目标接口访问视频设备,第一目标接口为基于第二操作系统的接口;将第一访问请求更新为第二访问请求,第二访问请求用于指示通过第二目标接口访问视频设备,第二目标接口为基于第一操作系统的接口;根据第二访问请求获得目标程序可处理的第一目标访问结果。本申请实施例无需修改目标程序原有的访问视频设备所定义的函数和流程即可使得目标程序访问视频设备,实现目标程序可以平滑移植到第一操作系统,移植的改动较小,提高了移植的效率,降低了移植的难度。In the embodiment of the present application, by executing the target program in the first operating system, the target program is developed based on the second operating system; receiving the first access request sent by the target program, the first access request is used to indicate access to the video device through the first target interface, The first target interface is an interface based on the second operating system; the first access request is updated to a second access request, the second access request is used to indicate access to the video device through the second target interface, and the second target interface is based on the first operation A system interface; obtaining a first target access result that can be processed by the target program according to the second access request. The embodiment of the present application can make the target program access the video device without modifying the functions and processes defined by the original access video device of the target program, so that the target program can be smoothly transplanted to the first operating system, and the transplantation changes are small, which improves the transplantation process. The efficiency reduces the difficulty of transplantation.

本申请实施例中提供了一种可能的实现方式,更新模块包括:A possible implementation is provided in the embodiment of this application, and the update module includes:

解析子模块,用于对第一访问请求进行解析,得到第一目标接口的标识和第一目标参数;第一目标参数是第一目标接口对应的接口函数可处理的参数;The parsing submodule is configured to parse the first access request to obtain the identifier of the first target interface and the first target parameter; the first target parameter is a parameter that can be processed by the interface function corresponding to the first target interface;

第一转换子模块,用于将第一目标接口的标识转换为第二目标接口的标识;A first converting submodule, configured to convert the identifier of the first target interface into the identifier of the second target interface;

第二转换子模块,用于将第一目标参数转换为第二目标参数,第二目标参数是第二目标接口对应的接口函数可处理的参数;The second conversion submodule is used to convert the first target parameter into a second target parameter, and the second target parameter is a parameter that can be processed by an interface function corresponding to the second target interface;

封装子模块,用于将第二目标接口的标识和第二目标参数进行封装,得到第二访问请求。The encapsulation submodule is configured to encapsulate the identifier of the second target interface and the second target parameter to obtain the second access request.

本申请实施例中提供了一种可能的实现方式,访问结果获得模块包括:A possible implementation is provided in the embodiment of this application, and the access result obtaining module includes:

第一处理结果获得子模块,用于根据第二访问请求中的第二目标接口的标识,并调用第二目标接口对应的接口函数对第二目标参数进行处理,得到第一处理结果;The first processing result obtaining submodule is configured to process the second target parameter by calling the interface function corresponding to the second target interface according to the identifier of the second target interface in the second access request, to obtain the first processing result;

第三转换子模块,用于将第一处理结果转换为第二处理结果;a third conversion submodule, configured to convert the first processing result into a second processing result;

将第二处理结果作为目标程序可处理的第一目标访问结果。The second processing result is used as the first target access result that can be processed by the target program.

本申请实施例中提供了一种可能的实现方式,第一转换子模块具体用于根据预先建立的第一映射关系,确定与第一目标接口的标识对应的第二目标接口的标识;An embodiment of the present application provides a possible implementation manner, the first conversion submodule is specifically configured to determine the identifier of the second target interface corresponding to the identifier of the first target interface according to the pre-established first mapping relationship;

第一映射关系为第一候选接口的标识和与第一候选接口的访问类型相同或相近的第二候选接口的标识之间的映射关系;第一候选接口和第二候选接口基于不同的操作系统;The first mapping relationship is the mapping relationship between the identifier of the first candidate interface and the identifier of the second candidate interface that has the same or similar access type as the first candidate interface; the first candidate interface and the second candidate interface are based on different operating systems ;

第二转换子模块具体用于根据预先建立的第二映射关系,确定第一目标参数对应的第二目标参数;The second conversion sub-module is specifically configured to determine a second target parameter corresponding to the first target parameter according to a pre-established second mapping relationship;

第二映射关系为第一候选接口对应的接口函数可处理的第一候选参数和相应的访问类型相同或相近的第二候选接口对应的接口函数可处理的、与第一候选参数含义相同或相近的第二候选参数之间的映射关系。The second mapping relationship is the first candidate parameter that can be processed by the interface function corresponding to the first candidate interface and the corresponding access type that is the same or similar to the interface function corresponding to the second candidate interface that can be processed and has the same or similar meaning as the first candidate parameter The mapping relationship between the second candidate parameters of .

本申请实施例中提供了一种可能的实现方式,第三转换子模块具体用于根据预先建立的第三映射关系,确定第一处理结果对应的第二处理结果;The embodiment of the present application provides a possible implementation manner, the third conversion sub-module is specifically configured to determine the second processing result corresponding to the first processing result according to the pre-established third mapping relationship;

第三映射关系为第一候选结果和第二候选结果之间的映射关系;The third mapping relationship is a mapping relationship between the first candidate result and the second candidate result;

第一候选结果为调用第一候选接口的接口函数对第一候选参数进行处理得到的结果;第二候选结果为调用与第一候选接口函的访问类型相同或相近的第二候选接口的接口函数对与第一候选参数存在第二映射关系的第二候选参数进行处理得到的结果。The first candidate result is the result obtained by calling the interface function of the first candidate interface to process the first candidate parameter; the second candidate result is the call of the interface function of the second candidate interface whose access type is the same as or similar to that of the first candidate interface function A result obtained by processing a second candidate parameter that has a second mapping relationship with the first candidate parameter.

本申请实施例中提供了一种可能的实现方式,第一访问请求或第二访问请求包括以下至少一种访问类型:A possible implementation is provided in this embodiment of the application, where the first access request or the second access request includes at least one of the following access types:

打开类型;启动预览类型;获取图像类型;停止预览类型;关闭类型;Open type; Start preview type; Get image type; Stop preview type; Close type;

其中,打开类型用于指示打开视频设备;Among them, the open type is used to indicate to open the video device;

启动预览类型用于指示预览视频设备采集的视频帧图像;The startup preview type is used to indicate the video frame image captured by the preview video device;

获取图像类型用于指示从缓冲区获取视频设备采集的视频帧图像;The acquired image type is used to indicate to obtain the video frame image captured by the video device from the buffer;

停止预览类型用于指示停止预览视频设备采集的视频帧图像;The stop preview type is used to indicate to stop previewing the video frame image collected by the video device;

关闭类型用于指示关闭视频设备。The shutdown type is used to indicate that the video device is turned off.

本申请实施例中提供了一种可能的实现方式,若第一访问请求的访问类型为启动预览类型,该访问结果获得模块还包括:A possible implementation is provided in the embodiment of the present application. If the access type of the first access request is the startup preview type, the access result obtaining module further includes:

注册子模块,用于注册帧回调函数;帧回调函数用于指示接收从视频设备采集的视频帧图像;The registration sub-module is used to register the frame callback function; the frame callback function is used to indicate to receive the video frame image collected from the video device;

运行子模块,用于运行帧回调函数,从视频设备获取视频帧图像,并将视频帧图像存储于缓冲区;缓冲区包括环形队列。The running sub-module is used to run the frame callback function, obtain the video frame image from the video device, and store the video frame image in the buffer; the buffer includes a circular queue.

本申请实施例的装置可执行本申请实施例所提供的方法,其实现原理相类似,本申请各实施例的装置中的各模块所执行的动作是与本申请各实施例的方法中的步骤相对应的,对于装置的各模块的详细功能描述具体可以参见前文中所示的对应方法中的描述,此处不再赘述。The device in the embodiment of the present application can execute the method provided in the embodiment of the present application, and its implementation principle is similar. The actions performed by the modules in the device in the embodiments of the present application are the same as the steps in the methods of the embodiments of the present application Correspondingly, for the detailed functional description of each module of the device, reference may be made to the description in the corresponding method shown above, which will not be repeated here.

本申请实施例中提供了一种电子设备,包括存储器、处理器及存储在存储器上的计算机程序,该处理器执行上述计算机程序以实现视频采集方法的步骤,与相关技术相比可实现:在第一操作系统中执行目标程序,目标程序基于第二操作系统开发;接收目标程序发送的第一访问请求,第一访问请求用于指示通过第一目标接口访问视频设备,第一目标接口为基于第二操作系统的接口;将第一访问请求更新为第二访问请求,第二访问请求用于指示通过第二目标接口访问视频设备,第二目标接口为基于第一操作系统的接口;根据第二访问请求获得目标程序可处理的第一目标访问结果。本申请实施例无需修改目标程序原有的访问视频设备所定义的函数和流程即可使得目标程序访问视频设备,实现目标程序可以平滑移植到第一操作系统,移植的改动较小,提高了移植的效率,降低了移植的难度。。An embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory. The processor executes the computer program to implement the steps of the video capture method. Compared with related technologies, the following can be realized: The target program is executed in the first operating system, and the target program is developed based on the second operating system; the first access request sent by the target program is received, and the first access request is used to indicate access to the video device through the first target interface, and the first target interface is based on The interface of the second operating system; the first access request is updated to the second access request, and the second access request is used to indicate access to the video device through the second target interface, and the second target interface is an interface based on the first operating system; according to the first access request The second access request obtains the first object access result that the object program can handle. The embodiment of the present application can make the target program access the video device without modifying the functions and processes defined by the original access video device of the target program, so that the target program can be smoothly transplanted to the first operating system, and the transplantation changes are small, which improves the transplantation process. The efficiency reduces the difficulty of transplantation. .

在一个可选实施例中提供了一种电子设备,如图4所示,图4所示的电子设备4000包括:处理器4001和存储器4003。其中,处理器4001和存储器4003相连,如通过总线4002相连。可选地,电子设备4000还可以包括收发器4004,收发器4004可以用于该电子设备与其他电子设备之间的数据交互,如数据的发送和/或数据的接收等。需要说明的是,实际应用中收发器4004不限于一个,该电子设备4000的结构并不构成对本申请实施例的限定。An optional embodiment provides an electronic device, as shown in FIG. 4 , the electronic device 4000 shown in FIG. 4 includes: a processor 4001 and a memory 4003 . Wherein, the processor 4001 is connected to the memory 4003 , such as through a bus 4002 . Optionally, the electronic device 4000 may further include a transceiver 4004, and the transceiver 4004 may be used for data interaction between the electronic device and other electronic devices, such as sending data and/or receiving data. It should be noted that, in practical applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not limit the embodiment of the present application.

处理器4001可以是CPU(Central Processing Unit,中央处理器),通用处理器,DSP(Digital Signal Processor,数据信号处理器),ASIC(Application SpecificIntegrated Circuit,专用集成电路),FPGA(Field Programmable Gate Array,现场可编程门阵列)或者其他可编程逻辑器件、晶体管逻辑器件、硬件部件或者其任意组合。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器4001也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,DSP和微处理器的组合等。The processor 4001 can be a CPU (Central Processing Unit, central processing unit), a general-purpose processor, a DSP (Digital Signal Processor, a data signal processor), an ASIC (Application Specific Integrated Circuit, an application specific integrated circuit), an FPGA (Field Programmable Gate Array, field programmable gate array) or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various illustrative logical blocks, modules and circuits described in connection with the present disclosure. The processor 4001 may also be a combination that implements computing functions, for example, a combination of one or more microprocessors, a combination of DSP and a microprocessor, and the like.

总线4002可包括一通路,在上述组件之间传送信息。总线4002可以是PCI(Peripheral Component Interconnect,外设部件互连标准)总线或EISA(ExtendedIndustry Standard Architecture,扩展工业标准结构)总线等。总线4002可以分为地址总线、数据总线、控制总线等。为便于表示,图4中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。Bus 4002 may include a path for communicating information between the components described above. The bus 4002 may be a PCI (Peripheral Component Interconnect, Peripheral Component Interconnect Standard) bus or an EISA (Extended Industry Standard Architecture, Extended Industry Standard Architecture) bus or the like. The bus 4002 can be divided into address bus, data bus, control bus and so on. For ease of representation, only one thick line is used in FIG. 4 , but it does not mean that there is only one bus or one type of bus.

存储器4003可以是ROM(Read Only Memory,只读存储器)或可存储静态信息和指令的其他类型的静态存储设备,RAM(Random Access Memory,随机存取存储器)或者可存储信息和指令的其他类型的动态存储设备,也可以是EEPROM(Electrically ErasableProgrammable Read Only Memory,电可擦可编程只读存储器)、CD-ROM(Compact DiscRead Only Memory,只读光盘)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质、其他磁存储设备、或者能够用于携带或存储计算机程序并能够由计算机读取的任何其他介质,在此不做限定。Memory 4003 can be ROM (Read Only Memory, read-only memory) or other types of static storage devices that can store static information and instructions, RAM (Random Access Memory, random access memory) or other types of static storage devices that can store information and instructions A dynamic storage device can also be EEPROM (Electrically Erasable Programmable Read Only Memory, Electrically Erasable Programmable Read-Only Memory), CD-ROM (Compact DiscRead Only Memory, CD-ROM) or other CD storage, CD storage (including compact CD, Laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation.

存储器4003用于存储执行本申请实施例的计算机程序,并由处理器4001来控制执行。处理器4001用于执行存储器4003中存储的计算机程序,以实现前述方法实施例所示的步骤。The memory 4003 is used to store the computer programs for executing the embodiments of the present application, and the execution is controlled by the processor 4001 . The processor 4001 is configured to execute the computer program stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.

其中,电子设备包可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、PDA(个人数字助理)、PAD(平板电脑)、PMP(便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。图4所示的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。Among them, the electronic equipment package may include but not limited to such as mobile phone, notebook computer, digital broadcast receiver, PDA (personal digital assistant), PAD (tablet computer), PMP (portable multimedia player), vehicle terminal (such as vehicle navigation terminal ) and the like as well as stationary terminals such as digital TVs, desktop computers and the like. The electronic device shown in FIG. 4 is only an example, and should not limit the functions and scope of use of the embodiments of the present disclosure.

本申请实施例提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时可实现前述方法实施例的步骤及相应内容。与现有技术相比可实现:在第一操作系统中执行目标程序,目标程序基于第二操作系统开发;接收目标程序发送的第一访问请求,第一访问请求用于指示通过第一目标接口访问视频设备,第一目标接口为基于第二操作系统的接口;将第一访问请求更新为第二访问请求,第二访问请求用于指示通过第二目标接口访问视频设备,第二目标接口为基于第一操作系统的接口;根据第二访问请求获得目标程序可处理的第一目标访问结果。本申请实施例无需修改目标程序原有的访问视频设备所定义的函数和流程即可使得目标程序访问视频设备,实现目标程序可以平滑移植到第一操作系统,移植的改动较小,提高了移植的效率,降低了移植的难度。An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiments can be realized. Compared with the prior art, it can be realized that the target program is executed in the first operating system, and the target program is developed based on the second operating system; the first access request sent by the target program is received, and the first access request is used to indicate the To access the video device, the first target interface is an interface based on the second operating system; the first access request is updated to a second access request, and the second access request is used to indicate access to the video device through the second target interface, and the second target interface is Based on the interface of the first operating system; obtaining the first target access result that can be processed by the target program according to the second access request. The embodiment of the present application can make the target program access the video device without modifying the functions and processes defined by the original access video device of the target program, so that the target program can be smoothly transplanted to the first operating system, and the transplantation changes are small, which improves the transplantation process. The efficiency reduces the difficulty of transplantation.

需要说明的是,本公开上述的计算机可读介质可以是计算机可读信号介质或者计算机可读介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。It should be noted that the above-mentioned computer-readable medium in the present disclosure may be a computer-readable signal medium or a computer-readable medium or any combination of the above two. A computer readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave carrying computer-readable program code therein. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can transmit, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device . Program code embodied on a computer readable medium may be transmitted by any appropriate medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

本申请实施例还提供了一种计算机程序产品,包括计算机程序,计算机程序被处理器执行时可实现前述方法实施例的步骤及相应内容。与现有技术相比可实现:在第一操作系统中执行目标程序,目标程序基于第二操作系统开发;接收目标程序发送的第一访问请求,第一访问请求用于指示通过第一目标接口访问视频设备,第一目标接口为基于第二操作系统的接口;将第一访问请求更新为第二访问请求,第二访问请求用于指示通过第二目标接口访问视频设备,第二目标接口为基于第一操作系统的接口;根据第二访问请求获得目标程序可处理的第一目标访问结果。本申请实施例无需修改目标程序原有的访问视频设备所定义的函数和流程即可使得目标程序访问视频设备,实现目标程序可以平滑移植到第一操作系统,移植的改动较小,提高了移植的效率,降低了移植的难度。The embodiment of the present application also provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps and corresponding content of the aforementioned method embodiments can be realized. Compared with the prior art, it can be realized that the target program is executed in the first operating system, and the target program is developed based on the second operating system; the first access request sent by the target program is received, and the first access request is used to indicate the To access the video device, the first target interface is an interface based on the second operating system; the first access request is updated to a second access request, and the second access request is used to indicate access to the video device through the second target interface, and the second target interface is Based on the interface of the first operating system; according to the second access request, the first target access result that can be processed by the target program is obtained. The embodiment of the present application can make the target program access the video device without modifying the functions and processes defined by the original access video device of the target program, so that the target program can be smoothly transplanted to the first operating system, and the transplantation changes are small, which improves the transplantation process. The efficiency reduces the difficulty of transplantation.

本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”、“1”、“2”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除图示或文字描述以外的顺序实施。The terms "first", "second", "third", "fourth", "1", "2", etc. (if any) in the description and claims of this application and the above drawings are used for Distinguishes between similar objects and does not necessarily describe a particular order or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein can be practiced in sequences other than those illustrated or described in writing.

应该理解的是,虽然本申请实施例的流程图中通过箭头指示各个操作步骤,但是这些步骤的实施顺序并不受限于箭头所指示的顺序。除非本文中有明确的说明,否则在本申请实施例的一些实施场景中,各流程图中的实施步骤可以按照需求以其他的顺序执行。此外,各流程图中的部分或全部步骤基于实际的实施场景,可以包括多个子步骤或者多个阶段。这些子步骤或者阶段中的部分或全部可以在同一时刻被执行,这些子步骤或者阶段中的每个子步骤或者阶段也可以分别在不同的时刻被执行。在执行时刻不同的场景下,这些子步骤或者阶段的执行顺序可以根据需求灵活配置,本申请实施例对此不限制。It should be understood that although arrows indicate various operation steps in the flow chart of the embodiment of the present application, the execution order of these steps is not limited to the order indicated by the arrows. Unless otherwise specified herein, in some implementation scenarios of the embodiments of the present application, the implementation steps in each flowchart may be performed in other orders as required. In addition, part or all of the steps in each flow chart may include multiple sub-steps or multiple stages based on actual implementation scenarios. Some or all of these sub-steps or stages may be executed at the same time, and each of these sub-steps or stages may also be executed at different times. In scenarios where execution times are different, the execution order of these sub-steps or stages can be flexibly configured according to requirements, which is not limited in this embodiment of the present application.

以上仅是本申请部分实施场景的可选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请的方案技术构思的前提下,采用基于本申请技术思想的其他类似实施手段,同样属于本申请实施例的保护范畴。The above are only optional implementations of some implementation scenarios of this application. It should be pointed out that for those of ordinary skill in the art, on the premise of not departing from the technical concept of this application, other similar methods based on the technical ideas of this application can be adopted. The means of implementation also belong to the scope of protection of the embodiments of the present application.

Claims (10)

1. A method of video capture, the method comprising:
executing a target program in a first operating system, wherein the target program is developed based on a second operating system;
receiving a first access request sent by the target program, wherein the first access request is used for indicating that video equipment is accessed through a first target interface, and the first target interface is an interface based on a second operating system;
updating the first access request into a second access request, wherein the second access request is used for indicating that the video equipment is accessed through a second target interface, and the second target interface is an interface based on a first operating system;
and obtaining a first target access result which can be processed by the target program according to the second access request.
2. The method of claim 1, wherein updating the first access request to a second access request comprises:
analyzing the first access request to obtain an identifier of a first target interface and a first target parameter; the first target parameter is a parameter which can be processed by an interface function corresponding to the first target interface;
converting the identifier of the first target interface into the identifier of a second target interface;
converting the first target parameter into a second target parameter, wherein the second target parameter is a parameter which can be processed by an interface function corresponding to the second target interface;
and encapsulating the identifier of the second target interface and the second target parameter to obtain a second access request.
3. The method according to claim 2, wherein the obtaining a first target access result that can be processed by the target program according to the second access request comprises:
determining a second target interface according to the identifier of the second target interface in the second access request, and calling an interface function corresponding to the second target interface to process the second target parameter to obtain a first processing result;
converting the first processing result into a second processing result;
and taking the second processing result as a first target access result which can be processed by the target program.
4. The method of claim 3, wherein translating the identity of the first target interface to the identity of the second target interface comprises:
determining the identifier of a second target interface corresponding to the identifier of the first target interface according to a pre-established first mapping relation;
the first mapping relation is a mapping relation between the identification of a first candidate interface and the identification of a second candidate interface which has the same or similar access type with the first candidate interface; the first candidate interface and the second candidate interface are based on different operating systems;
the converting the first target parameter into a second target parameter includes:
determining a second target parameter corresponding to the first target parameter according to a second mapping relation established in advance;
the second mapping relation is a mapping relation between a first candidate parameter which can be processed by an interface function corresponding to the first candidate interface and a second candidate parameter which can be processed by an interface function corresponding to a second candidate interface with the same or similar access type and has the same or similar meaning with the first candidate parameter.
5. The method of claim 4, wherein converting the first processing result into a second processing result comprises:
determining a second processing result corresponding to the first processing result according to a pre-established third mapping relation;
the third mapping relationship is a mapping relationship between the first candidate result and the second candidate result;
the first candidate result is obtained by calling an interface function of the first candidate interface to process the first candidate parameter; the second candidate result is obtained by calling an interface function of a second candidate interface with the same or similar access type as the first candidate interface to process a second candidate parameter with a second mapping relation with the first candidate parameter.
6. The method of any of claims 1-5, wherein the first access request or the second access request comprises at least one of the following access types:
an open type; starting a preview type; acquiring an image type; stopping the preview type; a shutdown type;
wherein the open type is used to indicate that the video device is opened;
the starting preview type is used for indicating to preview the video frame image collected by the video equipment;
the acquisition image type is used for indicating that the video frame image acquired by the video equipment is acquired from a buffer area;
the preview stopping type is used for indicating to stop previewing the video frame image collected by the video equipment;
the shutdown type is used to indicate that the video device is shut down.
7. The method according to claim 6, wherein before the invoking of the interface function corresponding to the second target interface to process the second target parameter if the access type of the first access request is a start preview type, the method further comprises
Registering a frame callback function; the frame callback function is used for indicating to receive video frame images collected from the video equipment head;
running the frame callback function, acquiring a video frame image from the video equipment, and storing the video frame image in a buffer area; the buffer includes a circular queue.
8. A video capture device, the device comprising:
the execution module is used for executing a target program in a first operating system, and the target program is developed based on a second operating system;
a receiving module, configured to receive a first access request sent by the target program, where the first access request is used to indicate that a video device is accessed through a first target interface, and the first target interface is an interface based on a second operating system;
an updating module, configured to update the first access request to a second access request, where the second access request is used to indicate that a video device is accessed through a second target interface, and the second target interface is an interface based on a first operating system;
and the access result obtaining module is used for obtaining a first target access result which can be processed by the target program according to the second access request.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory, characterized in that the processor executes the computer program to implement the steps of the method of any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202211042581.6A 2022-08-29 2022-08-29 Video capture method, device, electronic device and readable storage medium Pending CN115391063A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211042581.6A CN115391063A (en) 2022-08-29 2022-08-29 Video capture method, device, electronic device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211042581.6A CN115391063A (en) 2022-08-29 2022-08-29 Video capture method, device, electronic device and readable storage medium

Publications (1)

Publication Number Publication Date
CN115391063A true CN115391063A (en) 2022-11-25

Family

ID=84122471

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211042581.6A Pending CN115391063A (en) 2022-08-29 2022-08-29 Video capture method, device, electronic device and readable storage medium

Country Status (1)

Country Link
CN (1) CN115391063A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011160717A1 (en) * 2010-06-23 2011-12-29 International Business Machines Corporation Method for executing an instruction for selectively modifying adapter function parameters; computer system and computer program product for the same
CN112306645A (en) * 2020-12-24 2021-02-02 北京百度网讯科技有限公司 Transaction processing method, device, equipment, program and medium of Etheng virtual machine
CN113391860A (en) * 2020-03-11 2021-09-14 北京字节跳动网络技术有限公司 Service request processing method and device, electronic equipment and computer storage medium
CN114022103A (en) * 2021-10-26 2022-02-08 博锐尚格科技股份有限公司 Data processing method, apparatus, electronic device and readable storage medium
CN114706655A (en) * 2022-03-23 2022-07-05 阿里巴巴(中国)有限公司 Request processing method, computing device and computer storage medium
CN114816556A (en) * 2021-01-28 2022-07-29 北京金山云网络技术有限公司 Request processing method, apparatus and server

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011160717A1 (en) * 2010-06-23 2011-12-29 International Business Machines Corporation Method for executing an instruction for selectively modifying adapter function parameters; computer system and computer program product for the same
CN113391860A (en) * 2020-03-11 2021-09-14 北京字节跳动网络技术有限公司 Service request processing method and device, electronic equipment and computer storage medium
CN112306645A (en) * 2020-12-24 2021-02-02 北京百度网讯科技有限公司 Transaction processing method, device, equipment, program and medium of Etheng virtual machine
CN114816556A (en) * 2021-01-28 2022-07-29 北京金山云网络技术有限公司 Request processing method, apparatus and server
CN114022103A (en) * 2021-10-26 2022-02-08 博锐尚格科技股份有限公司 Data processing method, apparatus, electronic device and readable storage medium
CN114706655A (en) * 2022-03-23 2022-07-05 阿里巴巴(中国)有限公司 Request processing method, computing device and computer storage medium

Similar Documents

Publication Publication Date Title
CN110489323B (en) Visual RPC API debugging method, device, medium and equipment
US20140358262A1 (en) Multiple concurrent audio modes
CN115297183B (en) A data processing method, device, electronic equipment and storage medium
CN113761588A (en) Data verification method and device, terminal equipment and storage medium
WO2024041301A1 (en) Method and apparatus for generating unified abstract syntax tree, and program analysis method and apparatus
JP2016507796A (en) Realization of metadata storage subsystem
WO2021042936A1 (en) Video data processing method, apparatus, electronic device and computer-readable medium
US20250069279A1 (en) Image processing method and apparatus, and electronic device and storage medium
WO2024066757A1 (en) Data frame transmission method and apparatus, and readable storage medium
CN112835632B (en) A terminal capability calling method, device and computer storage medium
CN115174659A (en) Vehicle-mounted service container, service calling method, device and medium
CN113849449A (en) Communication system and information interaction method, device and medium
CN115391063A (en) Video capture method, device, electronic device and readable storage medium
CN117041980B (en) A network element management method, device, storage medium and electronic equipment
CN117492682A (en) Web-end audio/video processing method, device and storage medium
CN112398870B (en) Cross-platform protocol generation method, apparatus, system, device and storage medium
CN115550696A (en) Multimedia data transmission method, device, equipment, storage medium and program product
CN113779018B (en) A data processing method and device
CN115470800A (en) A robot dialogue method and device
CN114647411A (en) Programming interface loading method, device, electronic device and storage medium
CN113850055A (en) Data processing method, equipment, storage medium and product
CN117891767B (en) ADC chip module
CN118885424B (en) Port interaction method, switching chip, device, medium and product
CN114513561B (en) Information processing method, information processing device, electronic equipment and computer readable storage medium
US20250220070A1 (en) Network message processing method and device

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