可以使用海康SDK调用NET_DVR_STDXMLConfig进行透传,但是这种方式仍然比较麻烦。SDK的透传其实就是http的包装,可以完全撇开海康SDK,也就是通过http的方式获取或者设置,例如系统设置-基本信息
可以使用postman进行测试,注意鉴权方式选择Digest Auth。
直接上java代码
package com.cscec.hik.common.util;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import cn.hutool.json.JSONObject;
import cn.hutool.json.XML;
public class ISAPIUtil {
public static void main(String[] args) throws Exception {
String ip = "摄像头ip";
String username = "摄像头用户名";
String password = "摄像头密码";
String ftpISAPIUrl = "/ISAPI/System/deviceInfo";
JSONObject res = getISAPI(ip, username, password, ftpISAPIUrl);
System.out.println(res);
String putXml = "<?xml version: \"1.0\" encoding=\"UTF-8\"?><DeviceInfo xmlns=\"http://www.hikvision.com/ver20/XMLSchema\" version=\"2.0\">"
+ "<deviceName>摄像头1</deviceName>" + "<telecontrolID>88</telecontrolID>" + "</DeviceInfo>";
res = putISAPI(ip, username, password, ftpISAPIUrl, putXml);
System.out.println(res);
res = getISAPI(ip, username, password, ftpISAPIUrl);
System.out.println(res);
public static JSONObject getISAPI(String ip, String username, String password, String isapiUrl) throws Exception {
String url = "http://" + ip + isapiUrl;
HttpGet httpGet = new HttpGet(url);
Credentials creds = new UsernamePasswordCredentials(username, password);
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(AuthScope.ANY,creds);
CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
HttpResponse response = httpclient.execute(httpGet);
String resultString = EntityUtils.toString(response.getEntity(), "utf-8");
return XML.toJSONObject(resultString);
public static JSONObject putISAPI(String ip, String username, String password, String isapiUrl, String putXml)
throws Exception {
String url = "http://" + ip + isapiUrl;
HttpPut httpPut = new HttpPut(url);
Credentials creds = new UsernamePasswordCredentials(username, password);
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(AuthScope.ANY,creds);
CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
httpPut.setEntity(new StringEntity(putXml, "UTF-8"));
HttpResponse response = httpclient.execute(httpPut);
String resultString = EntityUtils.toString(response.getEntity(), "utf-8");
return XML.toJSONObject(resultString);
public static String post(String url, String params){
log.info("post url:" + url + " params:" + params);
String responseStr = "";
try(CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(url);
StringEntity stringEntity = new StringEntity(params, Charset.forName("UTF-8"));
httpPost.setHeader("Content-type", "application/json");
httpPost.setEntity(stringEntity);
Closeable
海康威视是一家领先的视频监控设备制造商,其摄像头产品可以通过 ISAPI(Intelligent Security Application Programming Interface)协议进行控制和管理。
ISAPI 协议是海康威视摄像头提供的一种编程接口,可以让开发者通过网络协议与海康摄像头进行通信,实现设备的远程控制和视频流的获取等功能。ISAPI 协议包括 HTTP 协议、RTSP 协议、以...
https://www.hikvision.com/cn/download_61.html
2.登录海康sdk包 库文件中的ClientDemo.exe 然后添加设备 只用填写ip,用户名,密码即可 端口默认为8000
我这里的设备是连接的公司的wifi 连接后就会显示ip,用户名为admin ,密码为设备登录管理界面的密码
添加后点击预览能显示表示参数正确
3.java开发
我这里的开发流程是 扫脸——回调函数逻辑判断——远程控门
最近在做一个项目时候要用到摄像头人脸抓拍,人脸识别等功能,原本使用海康的SDK就可以解决的,但是我们项目是在arm平台下开发的,而海康的SDK不支持arm平台,无奈联系的海康的技术支持,他们提供的了一种基于海康私有ISAPI 协议,通过HTTP进行摘要认证。
什么是摘要认证? 简单的说就是你要登录某个网站,网站会让你输入用户名密码才才能进行正常...
海康ISAPI使用相关
海康SDK对运行环境有要求,只支持x86系统,ARM或者单片机等无法使用。可以使用海康提供的ISAPI接口协议对设备进行操控
1.接口验证使用Digest Auth
2.使用设备ip地址+http端口号进行访问
在 .NET 中使用 HttpClient 时,你可以使用 HttpContent 和 HttpClient.PostAsync 方法来传递参数。
例如,假设你想要传递一个名为 "name" 的参数,可以这样做:
using (var client = new HttpClient())
var values = new Dictionary<string, string>
{ "name", "value" }
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("http://www.example.com/recepticle.aspx", content);
var responseString = await response.Content.ReadAsStringAsync();
你也可以使用 HttpClient.GetAsync 方法来传递参数,例如:
using (var client = new HttpClient())
var response = await client.GetAsync("http://www.example.com/recepticle.aspx?name=value");
var responseString = await response.Content.ReadAsStringAsync();
希望这对你有帮助!