赞
踩
因为工作需要,需要调用海康威视摄像头接口抓取Jpeg图片并保存到内存中,查找相关资料并整合,加上自己对官方提供的SDK文档,相关调用代码如下:
- public class TestHikvision {
-
- public static void main(String[] args) throws IOException {
- TestHikvision app = new TestHikvision();
-
- MonitorCameraInfo cameraInfo = new MonitorCameraInfo();//需要新建MonitorCameraInfo类
- cameraInfo.setCameraIp("****");
- cameraInfo.setCameraPort(8000);
- cameraInfo.setUserName("admin");
- cameraInfo.setUserPwd("****");
-
- app.getDVRConfig(cameraInfo);
- app.getDVRPic(cameraInfo);
- //app.Test_CaptureJpegPicture_new(cameraInfo);
- }
-
- public void getDVRConfig(MonitorCameraInfo cameraInfo) {
- HCNetSDK sdk = HCNetSDK.INSTANCE;
- //判断摄像头是否开启
- if (!sdk.NET_DVR_Init()) {
- System.out.println("SDK初始化失败");
- return;
- }
- //设置连接时间与重连
- //sdk.NET_DVR_SetConnectTime(2000, 1);
- //sdk.NET_DVR_SetReconnect(10000, true);
-
- NET_DVR_DEVICEINFO_V30 devinfo = new NET_DVR_DEVICEINFO_V30();// 设备信息
-
- //System.out.println("设备信息:"+devinfo);
-
- //登录信息
- NativeLong id = sdk.NET_DVR_Login_V30(cameraInfo.getCameraIp(), (short) cameraInfo.getCameraPort(),
- cameraInfo.getUserName(), cameraInfo.getUserPwd(), devinfo);
-
- cameraInfo.setUserId(id);// 返回一个用户编号,同时将设备信息写入devinfo
- //输出int数据
- //S
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。