
# openCamera(打开摄像头)
#### 接口描述
打开本端摄像头。
#### 注意事项
已经建立与OpenEye的WebSocket连接。
#### 方法定义
```
OpenEyeCall.prototype.openCamera = function(callId, callbacks)
```
#### 参数描述
表1参数说明 
| 参数名       | 类型                                                             | 可选/必选 | 描述                             |
|:---|:---|:---|:---|
| callId    | Number                                                         | 必选    | 当前通话的callID，在没有进行中的通话时则须设置为-1。 |
| callbacks | [Callback] | 可选    | 回调方法。                          |
   
 表2Callback 
| 参数名      | 类型       | 可选/必选 | 描述                                                                 |
|:---|:---|:---|:---|
| response | function | 必选    | 回调方法的入参请参考[表3] |
   
 表3回调方法的入参 
| 参数名         | 类型     | 描述                 |
|:---|:---|:---|
| description | String | 当前请求描述。            |
| result      | Number | 设置结果。0表示成功，其他表示失败。 |
| rsp         | Number | 内部消息编号。            |
   
![](https://support.huaweicloud.com/devg-openeye-cec/public_sys-resources/note_3.0-zh-cn.png)
回调方法的入参示例：
```
{
   "description" : "tsdk_control_camera",
   "result" : 0,
   "rsp" : 67759
}
```
#### 使用示例
```
function switchCameraMode() {
 var ischecked = document.getElementById("camera-control-toggle-button").checked;
 if (tupCurrentCallId == "") {
  tupCurrentCallId = -1;
 }
 if (ischecked) {
  console.info("switchCameraMode ischecked true.CallId is:"+tupCurrentCallId);
  this.global_openEye_SDK.openEyeCall.openCamera(tupCurrentCallId, {
   response: cameraModeResponse});
 } else {
  console.info("switchCameraMode ischecked false.CallId is:"+tupCurrentCallId);
  this.global_openEye_SDK.openEyeCall.closeCamera(tupCurrentCallId, {
   response: cameraModeResponse});
 }
}
function cameraModeResponse(data) {
    console.info(data);
    if (data.result == 0) {
        console.info("controlVideo Success.");
    } else {
        console.error("controlVideo failed.");
    }
}
```
