Skip to content

打开摄像头设备 - OpenCamera

函数简介

打开摄像头设备,返回视频句柄。

接口名称

OpenCamera

DLL调用

c
int64_t OpenCamera(int64_t instance, int32_t deviceIndex);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
deviceIndex整数型摄像头设备索引(默认0,表示第一个摄像头)。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long handle = ola.OpenCamera(0);
csharp
using OLAPlug;

var ola = new OLAPlugServer();
long handle = ola.OpenCamera(0);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
handle = ola.OpenCamera(0)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
long handle = ola.OpenCamera(0);
cpp
var ola = com("OlaPlug.OlaSoft")
var handle = ola.OpenCamera(0)
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
handle = ola.OpenCamera(0)
text
.局部变量 ola, OLAPlug
ola.创建 ()
handle = ola.OpenCamera(0)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var handle = ola.OpenCamera(0);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 handle = ola.OpenCamera(0)
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long handle = ola.OpenCamera(0);

原生 DLL 调用

cpp
OpenCamera(instance, 0);
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int OpenCamera(long ola, int deviceIndex);

OpenCamera(instance, 0);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ola.OpenCamera(instance, 0)

返回值

返回值说明
(返回值)长整数型:视频句柄,失败返回 0。

注意事项

项目说明
句柄用于后续的视频操作返回的句柄用于后续的视频操作,使用完毕后需调用 CloseVideo 释放。
确保摄像头设备已连接且未被其他程序占用确保摄像头设备已连接且未被其他程序占用。