标签:
基于海康威视SDK javaC/S http://www.hikvision.com/cn/download_61.html官网下载SDK开发包 配置文件 目录为lib/hc/HCNETSDK public HCNetSDK INSTANCE = CommonTools.loadLibrary(CommonTools.getLibPath() + "\\hc\\HCNetSDK", HCNetSDK.class); SDK初始化 private void initSDK() { boolean initSuccess = HCNetSDK.NET_DVR_Init(); if (!initSuccess) { showMessage("初始化失败HCNETSDK:" + getErrorMessage(INSTANCE.NET_DVR_GetLastError())); return; } HCNetSDK.NET_DVR_SetConnectTime(2000, 1); } 连接设备 private void login(String ip, short port, String username, String passwd) { if (userid != null && userid.longValue() >= 0) { HCNetSDK.NET_DVR_Logout(userid); } NET_DVR_DEVICEINFO_V30 lpDeviceInfo = new NET_DVR_DEVICEINFO_V30(); // 第二步 userid = HCNetSDK.NET_DVR_Login_V30(ip, port, username, passwd, lpDeviceInfo); if (HCNetSDK.NET_DVR_GetLastError() != 0) { userid = new NativeLong(-1); showMessage("登录失败:" + getErrorMessage(HCNetSDK.NET_DVR_GetLastError())); return; } System.out.println("序列号:" + new String(lpDeviceInfo.sSerialNumber)); System.out.println("通道数量:" + (lpDeviceInfo.byChanNum)); System.out.println("硬盘数量:" + (lpDeviceInfo.byDiskNum)); } -------------------------------------------------------------------------- 以下为实现截图和视频显示全部代码 package suigara.hardware.hc.htnet; import static suigara.hardware.hc.htnet.HCNetSDK.INSTANCE; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Panel; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.File; import java.util.ArrayList; import java.util.List; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JWindow; import suigara.hardware.hc.htnet.HCNetSDK.NET_DVR_CLIENTINFO; import suigara.hardware.hc.htnet.HCNetSDK.NET_DVR_DEVICEINFO_V30; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.platform.win32.WinDef.HWND; public class HCNetDemo { private static HCNetSDK HCNetSDK = INSTANCE; public static void main(String[] args) { new HCNetDemo(); } private NativeLong userid; private JFrame jf = new JFrame(); private List标签:
原文地址:http://www.cnblogs.com/sunflo/p/4276352.html