# jftech-camera
**Repository Path**: renkai721/jftech-camera
## Basic Information
- **Project Name**: jftech-camera
- **Description**: 快速对接杰峰云平台,可以通过接口来控制摄像头上下左右,放大和缩小。如果你的摄像头是通过以下APP来操作的都可以使用该插件来操作。APP包括【超级看看,XMEye,杰峰开发助手,蜂云SaaS,杰峰看看,EYE-U,5G看看,雄迈看看,JFEye;国外名字叫icsee】。开发者是HANGZHOU JFTECH CO.,LTD
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 5
- **Forks**: 0
- **Created**: 2024-08-15
- **Last Updated**: 2024-08-20
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# jftech-camera
快速对接杰峰云平台,可以通过接口来控制摄像头上下左右,放大和缩小。如果你的摄像头是通过以下APP来操作的都可以使用该插件来操作。APP包括【超级看看,XMEye,杰峰开发助手,蜂云SaaS,杰峰看看,EYE-U,5G看看,雄迈看看,JFEye;国外名字叫icsee】。只要App Store的开发者是HANGZHOU JFTECH CO.,LTD都可以使用该插件。
[源码地址](https://gitee.com/renkai721/jftech-camera.git)
# 目录
1. 项目介绍
1. 项目的优势在哪里
2. 杰峰云平台地址
3. 杰峰官网API
4. 为何会发起该项目?
2. 使用教程
## 更新日志
[更新请查看](update.md)
## 项目介绍
### 项目的优势在哪里
> 1.杰峰云官网API对接也是很清楚,但是需要传入的参数太多,比较复杂。
> 常规的RestTemplate或者Http代码写起来比较费时,于是在官方的SDK基础上将该接口打包成jar包来使用,避免多余的代码出现在自己的业务中。
### 杰峰云平台地址
> [杰峰云平台](https://auth.jftech.com/#/?lang=zh&source=aopv)
### 杰峰官网API
> [官方文档](https://docs.jftech.com/docs?menusId=54582398fd8d4248962354e92ac2e47a&siderId=68904eb1396e4f58a66ee7b37ae66922&lang=zh)
### 为何会发起该项目?
> 大家能够快速的对接杰峰云平台接口。
## 使用教程
> 1. 引入 pom.xml
```xml
io.gitee.renkai721
jftech-camera
1.0.0
```
#### Demo功能示例
---
> 1. 初始化
```
JLinkClient jClient = new JLinkClient(
"e0534f3240274897821a126be19b6d46",
"5b027c14d371332e88a9cbae30375ee7",
"fd664d5fa6974ec09023818f68b23212",
5);
// 初始化设备
JLinkDevice jDevice = new JLinkDevice(jClient, "1234567890123457", "device Username", "device password");
```
> 2. 设备绑定
```
String url = String.format("%s/%s", JLinkDomain.OPENAPI_DOMAIN.get(), JLinkDeviceRequestUrl.DEVICE_BIND.get());
Map bodyParam = new HashMap<>();
bodyParam.put("sn", "1234567890123457");
JLinkHttpUtil.httpsRequest(url, "POST", JLinkHeaderUtil.map(jClient), new Gson().toJson(bodyParam));
```
> 3. 获取设备接口访问令牌(deviceToken)
```
String deviceToken = jDevice.getDeviceToken();
```
> 4. 获取设备状态
```
DeviceStatusData statusResponse = jDevice.deviceStatus();
```
> 5. 获取设备直播地址
```
// 这种方法返回的是h265格式的视频
JLinkUser jUser = new JLinkUser(jClient);
String liveStream = jDevice.deviceLivestream(DeviceLiveStreamEnum.STREAM_EXTRA.get(), DeviceLiveStreamEnum.MEDIATYPE_HLS.get(), DeviceLiveStreamEnum.PROTOCOL_TS.get(), jUser);
```
> 6. 获取h264设备直播地址
```
// 注意,VUE的vue-video-player只能播放h64格式的m3u8
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH, 2);
Date futureTime = calendar.getTime();
try {
JLinkClient jClient = new JLinkClient(uuid, appKey, appSecret,moveCard);
JLinkDevice jDevice = new JLinkDevice(jClient, sn, username, password);
JLinkUser jUser = new JLinkUser(jClient);
String liveStream = jDevice.deviceLivestream(
"0", "1", "hls",
"ts", String.valueOf(futureTime.getTime()),
"h264", "aac", jUser);
log.info("liveStream={}",liveStream);
}catch (Exception e){
e.printStackTrace();
}
```
> 7. 设备登录
```
jDevice.login();
```
> 8. 获取设备系统能力集
```
jDevice.deviceAbility(JLinkDeviceAbilityEnum.SYSTEMFUNCTION);
```
> 9. 设备配置(以获取设备DAS配置为例)
```
try {
NetWorkDasConfig dasConfig;
dasConfig = (NetWorkDasConfig) jDevice.getConfig(JLinkDeviceConfigTypeEnum.NETWORKDAS);
JLinkLog.i(new Gson().toJson(dasConfig));
/**
* Set the device configuration Take NetWorkDasConfig as an example
* Get dasConfig from GetConfig request
*/
try {
dasConfig.getNetWorkDAS().setServerAddr("127.0.0.1");
jDevice.setConfig(dasConfig);
} catch (JLinkDeviceSetConfigException e) {
JLinkLog.e("SetConfig Error:" + e);
}
} catch (JLinkDeviceGetConfigException e) {
JLinkLog.e("GetConfig Error:" + e);
}
```
> 10. 设备操作(云台方向控制)
```
try {
PtzDirectionControlDTO ptzDirectionControlDTO = new PtzDirectionControlDTO();
// DirectionUp=上,DirectionDown=下,DirectionLeft=左,DirectionRight=右
// DirectionLeftUp=左上,DirectionLeftDown=左下,DirectionRightUp=右上,DirectionRightDown=右下
// FocusNear=放大,FocusFar=缩小
ptzDirectionControlDTO.getOpptzControl().setCommand(PTZControlEnum.DirectionRight);
//channel 1
ptzDirectionControlDTO.getOpptzControl().getParameter().setChannel(0);
//0~65535: start exercising -1: stop exercising
ptzDirectionControlDTO.getOpptzControl().getParameter().setPreset(1);
//rotation speed
ptzDirectionControlDTO.getOpptzControl().getParameter().setStep(1);
jDevice.deviceOperate(ptzDirectionControlDTO);
} catch (JLinkDeviceOperateException e) {
JLinkLog.e("Operate Error:" + e);
}
```
> 11. 设备抓图
```
try {
String picUrl = jDevice.capture(0);
JLinkLog.i(picUrl);
} catch (JLinkDeviceCaptureException e) {
JLinkLog.e(e.toString());
}
```
> 12. 设置wifi
```
try {
JLinkClient jClient = new JLinkClient(uuid, appKey, appSecret,moveCard);
JLinkDevice jDevice = new JLinkDevice(jClient, sn, username, password);
NetWorkWifiConfig dasConfig = (NetWorkWifiConfig) jDevice.getConfig(JLinkDeviceConfigTypeEnum.NETWORKWIFI);
dasConfig.getNetWorkWifiDTO().setSsid("你的wifi名称");
dasConfig.getNetWorkWifiDTO().setKeys("你的wifi密码");
jDevice.setConfig(dasConfig);
}catch (Exception e){
log.error("set wifi error");
e.printStackTrace();
throw new Exception("set wifi error");
}
```