去除不需要的sdk调用代码

This commit is contained in:
weitang 2025-04-23 15:15:16 +08:00
parent 4c4f61d496
commit fcf11fe63c
61 changed files with 6 additions and 9305 deletions

View File

@ -86,40 +86,8 @@
<artifactId>thumbnailator</artifactId> <artifactId>thumbnailator</artifactId>
<version>0.4.19</version> <version>0.4.19</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.penn</groupId>-->
<!-- <artifactId>jna</artifactId>-->
<!-- <version>0.0.1-SNAPSHOT</version>-->
<!-- <scope>system</scope>-->
<!-- <systemPath>${project.basedir}/src/main/resources/lib/jna.jar</systemPath>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.sun.jna</groupId>-->
<!-- <artifactId>jna</artifactId>-->
<!-- <version>3.0.9</version>-->
<!-- </dependency>-->
<!--本地动态库访问插件JNA-->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.12.1</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.12.1</version>
</dependency>
<dependency>
<groupId>com.penn</groupId>
<artifactId>examples.jar</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/examples.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>com.alibaba.fastjson2</groupId> <groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension</artifactId> <artifactId>fastjson2-extension</artifactId>

View File

@ -1160,7 +1160,6 @@ public class SubstationPatroldeviceController {
String password = split[1]; String password = split[1];
String ip = split[2]; String ip = split[2];
log.info("-------调用硬盘录像机存储方法--------"); log.info("-------调用硬盘录像机存储方法--------");
log.info("DLL_PATH" + CameraUtil.DLL_PATH);
String nvrStatus = CameraUtil.getStorageStatus("haikang", ip, (short) 8000, username, password); String nvrStatus = CameraUtil.getStorageStatus("haikang", ip, (short) 8000, username, password);
JSONObject jsonObject = JSONUtil.parseObj(nvrStatus); JSONObject jsonObject = JSONUtil.parseObj(nvrStatus);
// 硬盘容量 // 硬盘容量

View File

@ -4,15 +4,9 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.hutool.system.OsInfo;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yfd.platform.config.HttpServerConfig; import com.yfd.platform.config.HttpServerConfig;
import com.yfd.platform.constant.SystemCode; import com.yfd.platform.constant.SystemCode;
import com.yfd.platform.modules.deviceapi.GeneralFunction.AddOSD;
import com.yfd.platform.modules.deviceapi.GeneralFunction.CaptureJPEGPicture;
import com.yfd.platform.modules.deviceapi.GeneralFunction.Login;
import com.yfd.platform.modules.deviceapi.Thermometry.JpegWithAppendData;
import com.yfd.platform.modules.deviceapi.Thermometry.ThreadGetOnceTempData;
import com.yfd.platform.utils.HttpRESTfulUtils; import com.yfd.platform.utils.HttpRESTfulUtils;
import com.yfd.platform.utils.SpringContextHolder; import com.yfd.platform.utils.SpringContextHolder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -24,9 +18,10 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.text.DecimalFormat; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.*; import java.util.Map;
/** /**
* *
@ -37,36 +32,8 @@ import java.util.*;
@Slf4j @Slf4j
public class CameraUtil { public class CameraUtil {
public static String DLL_PATH;
static {
String path = "E:\\project\\riis-server-java\\riis-server\\src\\main\\resources\\lib" +
"\\HCNetSDK.dll";
// String path = "D:\\变电站项目1108\\net-dev-sdk-231109\\net-dev-sdk-231109\\win64\\HKNetDeviceSDK" +
// "\\HCNetSDK.dll";
OsInfo osInfo = new OsInfo();
if (osInfo.isLinux()) {
String loadLibrary = "/usr/lib64/lib/hkliblinux64/";
path = loadLibrary + "libhcnetsdk.so";
}
DLL_PATH = path;
}
static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
//用户句柄
public static int lUserID = -1;
//人员信息状态
// static int dwState = -1;
//下发人脸数据状态
// static int dwFaceState = -1;
//设备字符集
// static int iCharEncodeType = 0;
public static void main(String[] args) { public static void main(String[] args) {
// getTemperature("haikang", "192.168.0.21", (short) 8000, "admin", "hkdq8888", "", "",
// "");
// getStorageStatus("haikang", "192.168.1.39", (short) 8000, "admin", "JY123456");
getTemperature("haikang", "192.168.1.66", (short) 8000, "admin", "JY123456", null, null, null);
} }
/********************************** /**********************************
@ -181,11 +148,10 @@ public class CameraUtil {
// return getDaHuaTemperature(ip, port, username, password, outsideAngle); // return getDaHuaTemperature(ip, port, username, password, outsideAngle);
return ""; return "";
} else if ("yushi".equals(manufacturer)) { } else if ("yushi".equals(manufacturer)) {
//throw new RuntimeException("暂时没有 “宇视” SDK");
return ""; return "";
} else if ("haikang".equals(manufacturer) || "Hikvision".equals(manufacturer)) { } else if ("haikang".equals(manufacturer) || "Hikvision".equals(manufacturer)) {
log.info("进入getTemperature"); log.info("进入getTemperature");
return getHikTemperature(ip, port, username, password, outsideAngle, csvFilePath, filePath); return "";
} else if ("dali".equals(manufacturer)) { } else if ("dali".equals(manufacturer)) {
return getDaLiTemperature(ip, port, username, password, outsideAngle, csvFilePath); return getDaLiTemperature(ip, port, username, password, outsideAngle, csvFilePath);
} else { } else {
@ -194,56 +160,6 @@ public class CameraUtil {
} }
} }
public static String captureJPEGPicture(String manufacturer, String ip, short port, String username,
String password, int iChannelNum, String imagefilename) {
// 根据生产厂家判断对应方法
if ("dahua".equals(manufacturer)) {
return "暂时没有 “大华” SDK";
} else if ("yushi".equals(manufacturer)) {
return "暂时没有 “宇视” SDK";
} else if ("haikang".equals(manufacturer)) {
return HikCaptureJPEGPicture(ip, port, username, password, iChannelNum, imagefilename);
} else {
return "暂时没有该生产厂家";
}
}
/**********************************
* 用途说明: 海康摄像机抓图
* 参数说明 ip 摄像机ip
* 参数说明 port 摄像机端口
* 参数说明 username 用户名
* 参数说明 password 密码
* 参数说明 iChannelNum 通道号
* 返回值说明: java.lang.String
***********************************/
public static String HikCaptureJPEGPicture(String ip, short port, String username, String password,
int iChannelNum,String imagefilename) {
/*初始SDK*/
hCNetSDK.NET_DVR_Init();
// hCNetSDK.NET_DVR_SetLogToFile(3, "D:/JavaDemoLog", true);
//TODO 库加载代码 设置异常消息回调 报警分离
//登陆
Login login = new Login();
lUserID = login.getlUserID(ip, port, username, password);
if (lUserID == -1) {
return "登录失败";
}
// 抓取图片到指定文件夹
ThreadGetOnceTempData threadGetOnceTempData = new ThreadGetOnceTempData();
String result = threadGetOnceTempData.threadGetOnceTempData(lUserID, 1);
CaptureJPEGPicture captureJPEGPicture = new CaptureJPEGPicture();
captureJPEGPicture.captureJPEGPicture(lUserID, iChannelNum, (short) 9, imagefilename);
// 登出
hCNetSDK.NET_DVR_Logout(lUserID);
return result;
}
/********************************** /**********************************
* 用途说明: 大立热成像温度获取 * 用途说明: 大立热成像温度获取
* 参数说明 ip 摄像机ip * 参数说明 ip 摄像机ip
@ -364,90 +280,6 @@ public class CameraUtil {
return null; return null;
} }
/**********************************
* 用途说明: 海康热成像温度获取
* 参数说明 ip 摄像机ip
* 参数说明 port 摄像机端口
* 参数说明 username 用户名
* 参数说明 password 密码
* 参数说明 region 测温区域
* 返回值说明: java.lang.String
***********************************/
public static String getHikTemperature(String ip, short port, String username, String password, String region,
String csvFilePath, String filePath) {
/*初始SDK*/
hCNetSDK.NET_DVR_Init();
// hCNetSDK.NET_DVR_SetLogToFile(3, "D:/JavaDemoLog", true);
//登陆
Login login = new Login();
lUserID = login.getlUserID(ip, port, username, password);
if (lUserID == -1) {
return "";
}
// 获取spring bean HttpServerConfig 类实例
// HttpServerConfig config =
// SpringContextHolder.getBean(HttpServerConfig.class);
JpegWithAppendData jpegWithAppendData = new JpegWithAppendData();
String[][] temp = jpegWithAppendData.jpegWithAppendData1(lUserID, 2, csvFilePath);
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(region);
String type = jsonObject.getStr("type");
String result;
DecimalFormat format = new DecimalFormat("0.0");
JSONArray pos = jsonObject.getJSONArray("pos");
Object o = pos.get(0);
cn.hutool.json.JSONObject jsonObject1 = JSONUtil.parseObj(o);
File srcImgFile = new File(csvFilePath);
//文件转化为图片
Image srcImg = null;
try {
srcImg = ImageIO.read(srcImgFile);
} catch (IOException e) {
log.error(e.getMessage());;
}
if (srcImg == null) {
return "";
}
//获取图片的宽
int srcImgWidth = srcImg.getWidth(null);
//获取图片的高
int srcImgHeight = srcImg.getHeight(null);
// 获取图片比例
int width = srcImgWidth / temp.length;
int height = srcImgHeight / temp[0].length;
int x1 = Convert.convert(Integer.class, jsonObject1.getStr("x")) == 0 ? 0 : Convert.convert(Integer.class,
jsonObject1.getStr("x")) / width;
int y1 = Convert.convert(Integer.class, jsonObject1.getStr("y")) == 0 ? 0 : Convert.convert(Integer.class,
jsonObject1.getStr("y")) / height;
if ("point".equals(type)) {
// 点测温
// 坐标
String max = format.format(Double.valueOf(temp[x1][y1]));
result = max + "," + max;
} else {
// 框测温
// 去除左上角和右下角坐标
Object o1 = pos.get(2);
cn.hutool.json.JSONObject jsonObject2 = JSONUtil.parseObj(o1);
int x2 = Convert.convert(Integer.class, jsonObject2.getStr("x")) == 0 ? 0 : Convert.convert(Integer.class
, jsonObject2.getStr("x")) / width;
int y2 = Convert.convert(Integer.class, jsonObject2.getStr("y")) == 0 ? 0 : Convert.convert(Integer.class
, jsonObject2.getStr("y")) / height;
List<String> tempList = new ArrayList<>();
for (int i = x1; i <= x2; i++) {
tempList.addAll(Arrays.asList(temp[i]).subList(y1, y2 + 1));
}
Collections.sort(tempList);
String max = format.format(Double.valueOf(tempList.get(tempList.size() - 1)));
String min = format.format(Double.valueOf(tempList.get(0)));
result = max + "," + min;
}
// 登出
hCNetSDK.NET_DVR_Logout(lUserID);
return result;
}
public static String getStorageStatus(String manufacturer, String ip, short port, String username, public static String getStorageStatus(String manufacturer, String ip, short port, String username,
String password) { String password) {
@ -460,34 +292,13 @@ public class CameraUtil {
return ""; return "";
} else if ("haikang".equals(manufacturer) || "Hikvision".equals(manufacturer)) { } else if ("haikang".equals(manufacturer) || "Hikvision".equals(manufacturer)) {
log.info("进入getStorageStatus"); log.info("进入getStorageStatus");
return getHikStorageStatus(ip, port, username, password); return "";
} else { } else {
//throw new RuntimeException("暂时没有该生产厂家"); //throw new RuntimeException("暂时没有该生产厂家");
return ""; return "";
} }
} }
//String manufacturer, String ip, short port, String username,
// String password
public static String getHikStorageStatus(String ip, short port, String username, String password) {
/*初始SDK*/
hCNetSDK.NET_DVR_Init();
// hCNetSDK.NET_DVR_SetLogToFile(3, "D:/JavaDemoLog", true);
//登陆
Login login = new Login();
lUserID = login.getlUserID(ip, port, username, password);
if (lUserID == -1) {
return null;
}
AddOSD addOSD = new AddOSD();
cn.hutool.json.JSONObject result = addOSD.getHDCFG(lUserID, 1);
// 登出
hCNetSDK.NET_DVR_Logout(lUserID);
return result.toString();
}
public static void addWaterMark(String srcImgPath, String tarImgPath, String waterMarkContent, public static void addWaterMark(String srcImgPath, String tarImgPath, String waterMarkContent,
Color markContentColor, Color markContentColor,
Font font) { Font font) {

View File

@ -1,126 +0,0 @@
package com.yfd.platform.modules.deviceapi.GeneralFunction;
import cn.hutool.json.JSONException;
import cn.hutool.json.JSONObject;
import com.sun.jna.ptr.IntByReference;
import com.yfd.platform.modules.deviceapi.HCNetSDK;
import lombok.extern.slf4j.Slf4j;
import java.io.UnsupportedEncodingException;
/**
* Created by panting6 on 2022/4/14.
*/
@Slf4j
public class AddOSD {
static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
public void addOSD(int lUserID, int iChannelNum) {
HCNetSDK.NET_DVR_PICCFG_V40 piccfc40 = new HCNetSDK.NET_DVR_PICCFG_V40();
piccfc40.dwSize = piccfc40.size();
IntByReference lpBytesReturned = new IntByReference(0);
if (!hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_PICCFG_V40, iChannelNum,
piccfc40.getPointer(), piccfc40.size(), lpBytesReturned)) {
log.info("获得图像参数失败,错误号:" + hCNetSDK.NET_DVR_GetLastError());
} else {
piccfc40.read();
String name = new String(piccfc40.sChanName);
log.info("获得图像参数成功,通道号名称" + name + "OSD属性:" + piccfc40.byOSDAttrib + ",字体大小:" + piccfc40.byFontSize + ",预览的图象上是否显示OSD" + piccfc40.dwShowOsd);
}
piccfc40.sChanName = "camera 01".getBytes();
piccfc40.dwVideoFormat = 2;
piccfc40.dwShowChanName = 1;
piccfc40.wShowNameTopLeftX = 496;
piccfc40.wShowNameTopLeftY = 512;
piccfc40.dwEnableHide = 0;
piccfc40.dwShowOsd = 1;
piccfc40.wOSDTopLeftX = 0;
piccfc40.wOSDTopLeftY = 32;
piccfc40.byOSDType = 1;
piccfc40.byDispWeek = 1;
piccfc40.byOSDAttrib = 4;
piccfc40.byHourOSDType = 0;
piccfc40.byFontSize = (byte) 0xff;
piccfc40.byOSDColorType = 0;
piccfc40.byAlignment = 0;
piccfc40.write();
if (!hCNetSDK.NET_DVR_SetDVRConfig(lUserID, HCNetSDK.NET_DVR_SET_PICCFG_V40, iChannelNum,
piccfc40.getPointer(), piccfc40.size())) {
log.info("设置图像参数失败,错误号:" + hCNetSDK.NET_DVR_GetLastError());
}
log.info("设置图像参数成功");
}
public JSONObject getHDCFG(int lUserID, int iChannelNum) throws JSONException {
HCNetSDK.NET_DVR_HDCFG piccfc40 = new HCNetSDK.NET_DVR_HDCFG();
piccfc40.dwSize = piccfc40.size();
IntByReference lpBytesReturned = new IntByReference(0);
if (!hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_HDCFG, iChannelNum, piccfc40.getPointer(),
piccfc40.size(), lpBytesReturned)) {
log.info("获得图像参数失败,错误号:" + hCNetSDK.NET_DVR_GetLastError());
return null;
} else {
piccfc40.read();
HCNetSDK.NET_DVR_SINGLE_HD[] struHDInfo = piccfc40.struHDInfo;
HCNetSDK.NET_DVR_SINGLE_HD netDvrSingleHd = struHDInfo[0];
JSONObject jsonObject = new JSONObject();
jsonObject.putOnce("dwCapacity", netDvrSingleHd.dwCapacity);
jsonObject.putOnce("dwFreeSpace", netDvrSingleHd.dwFreeSpace);
jsonObject.putOnce("dwHdStatus", netDvrSingleHd.dwHdStatus);
jsonObject.putOnce("byHDAttr", netDvrSingleHd.byHDAttr);
jsonObject.putOnce("dwHDNo", netDvrSingleHd.dwHDNo);
jsonObject.putOnce("dwHdGroup", netDvrSingleHd.dwHdGroup);
return jsonObject;
}
}
public void showString(int lUserID, int iChannelNum) throws UnsupportedEncodingException {
HCNetSDK.NET_DVR_SHOWSTRING_V30 showstring30 = new HCNetSDK.NET_DVR_SHOWSTRING_V30();
showstring30.dwSize = showstring30.size();
IntByReference lpBytesReturned = new IntByReference(0);
if (!hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_SHOWSTRING_V30, iChannelNum,
showstring30.getPointer(), showstring30.size(), lpBytesReturned)) {
log.info("获取字符叠加失败,错误号:" + hCNetSDK.NET_DVR_GetLastError());
} else {
showstring30.read();
String name = new String(showstring30.struStringInfo[0].sString);
log.info("获取字符叠加成功,预览的图象上是否显示字符" + showstring30.struStringInfo[0].wShowString + ",该字符长度:"
+ showstring30.struStringInfo[0].wStringSize + ",字符显示位置的x坐标" + showstring30.struStringInfo[0].wShowStringTopLeftX
+ ",字符显示位置的Y坐标" + showstring30.struStringInfo[0].wShowStringTopLeftY + ",要显示的字符内容:" + name);
}
showstring30.struStringInfo[0].wShowString = 1;
showstring30.struStringInfo[0].wStringSize = 9;
showstring30.struStringInfo[0].wShowStringTopLeftX = 16;
showstring30.struStringInfo[0].wShowStringTopLeftY = 96;
showstring30.struStringInfo[0].sString = "hhhhhh".getBytes();
if (!hCNetSDK.NET_DVR_SetDVRConfig(lUserID, HCNetSDK.NET_DVR_SET_SHOWSTRING_V30, iChannelNum,
showstring30.getPointer(), showstring30.size())) {
log.info("设置字符叠加失败,错误号:" + hCNetSDK.NET_DVR_GetLastError());
} else {
showstring30.read();
String rename = new String(showstring30.struStringInfo[0].sString);
log.info("设置字符叠加成功,预览的图象上是否显示字符" + showstring30.struStringInfo[0].wShowString + ",该字符长度:"
+ showstring30.struStringInfo[0].wStringSize + ",字符显示位置的x坐标" + showstring30.struStringInfo[0].wShowStringTopLeftX
+ ",字符显示位置的Y坐标" + showstring30.struStringInfo[0].wShowStringTopLeftY + ",要显示的字符内容:" + rename);
}
}
}

View File

@ -1,46 +0,0 @@
package com.yfd.platform.modules.deviceapi.GeneralFunction;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.yfd.platform.modules.deviceapi.HCNetSDK;
import lombok.extern.slf4j.Slf4j;
/**
* Created by panting6 on 2021/8/12.
*/
@Slf4j
public class CaptureJPEGPicture {
static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
public String captureJPEGPicture(int lUserID, int iChannelNum,short picsize,String imagefilename)
{
HCNetSDK.NET_DVR_JPEGPARA lpJpegPara = new HCNetSDK.NET_DVR_JPEGPARA();
lpJpegPara.wPicQuality = 1;
lpJpegPara.wPicSize = picsize;
/* SimpleDateFormat sf = new SimpleDateFormat("yyyymmddHHmmss");
String newName = sf.format(new Date());*/
if(!hCNetSDK.NET_DVR_CaptureJPEGPicture(lUserID,iChannelNum,lpJpegPara,imagefilename))
{
return "设备抓图失败";
}
else{
return "设备抓图成功";
}
}
public void captureJPEGPictureNew(int lUserID, int iChannelNum, short picsize)
{
HCNetSDK.NET_DVR_JPEGPARA lpJegPara = new HCNetSDK.NET_DVR_JPEGPARA();
lpJegPara.wPicQuality = 1;
lpJegPara.wPicSize = picsize;
Pointer struJpegPicBuffer = null;
IntByReference lpSizeReturned = new IntByReference(0);
if(!hCNetSDK.NET_DVR_CaptureJPEGPicture_NEW(lUserID,iChannelNum,lpJegPara,struJpegPicBuffer,picsize,lpSizeReturned))
{
log.error("设备抓图到内存失败,错误码:" + hCNetSDK.NET_DVR_GetLastError());
}
else{
log.info("设备抓图到内存成功,返回图片数据长度:" + lpSizeReturned);
}
}
}

View File

@ -1,42 +0,0 @@
package com.yfd.platform.modules.deviceapi.GeneralFunction;
import com.yfd.platform.modules.deviceapi.HCNetSDK;
import lombok.extern.slf4j.Slf4j;
/**
* 登录
*/
@Slf4j
public class Login {
static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
public static int lUserID;//用户句柄
public int getlUserID(String m_sDeviceIP,short wPort,String m_sUsername,String m_sPassword){
//注册
HCNetSDK.NET_DVR_USER_LOGIN_INFO m_strLoginInfo = new HCNetSDK.NET_DVR_USER_LOGIN_INFO();//设备登录信息
m_strLoginInfo.sDeviceAddress = new byte[HCNetSDK.NET_DVR_DEV_ADDRESS_MAX_LEN];
System.arraycopy(m_sDeviceIP.getBytes(), 0, m_strLoginInfo.sDeviceAddress, 0, m_sDeviceIP.length());
m_strLoginInfo.sUserName = new byte[HCNetSDK.NET_DVR_LOGIN_USERNAME_MAX_LEN];
System.arraycopy(m_sUsername.getBytes(), 0, m_strLoginInfo.sUserName, 0, m_sUsername.length());
m_strLoginInfo.sPassword = new byte[HCNetSDK.NET_DVR_LOGIN_PASSWD_MAX_LEN];
System.arraycopy(m_sPassword.getBytes(), 0, m_strLoginInfo.sPassword, 0, m_sPassword.length());
m_strLoginInfo.wPort = wPort;
m_strLoginInfo.bUseAsynLogin = false; //是否异步登录0- 1-
m_strLoginInfo.write();
HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40();//设备信息
lUserID = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
if (lUserID == -1) {
log.error("登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
return -1;
} else {
log.info("登录成功!");
return lUserID;
}
}
}

View File

@ -1,208 +0,0 @@
package com.yfd.platform.modules.deviceapi.Thermometry;
import com.yfd.platform.modules.deviceapi.HCNetSDK;
import com.yfd.platform.utils.FileUtil;
import lombok.extern.slf4j.Slf4j;
import java.io.*;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by panting6 on 2021/2/21.
*/
@Slf4j
public class JpegWithAppendData {
static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
public void jpegWithAppendData(int lUserID, int iChannelNum) {
boolean bRet = false;
HCNetSDK.NET_DVR_JPEGPICTURE_WITH_APPENDDATA m_strJpegWithAppendData =
new HCNetSDK.NET_DVR_JPEGPICTURE_WITH_APPENDDATA();
m_strJpegWithAppendData.dwSize = m_strJpegWithAppendData.size();
HCNetSDK.BYTE_ARRAY ptrJpegByte = new HCNetSDK.BYTE_ARRAY(4 * 1024 * 1024);
HCNetSDK.BYTE_ARRAY ptrP2PDataByte = new HCNetSDK.BYTE_ARRAY(2 * 1024 * 1024);
HCNetSDK.BYTE_ARRAY ptrVisiblePicByte = new HCNetSDK.BYTE_ARRAY(40 * 1024 * 1024);
m_strJpegWithAppendData.pJpegPicBuff = ptrJpegByte.getPointer();
m_strJpegWithAppendData.pP2PDataBuff = ptrP2PDataByte.getPointer();
m_strJpegWithAppendData.pVisiblePicBuff = ptrVisiblePicByte.getPointer();
m_strJpegWithAppendData.dwJpegPicLen = 4 * 1024 * 1024;
m_strJpegWithAppendData.dwP2PDataLen = 2 * 1024 * 1024;
m_strJpegWithAppendData.dwVisiblePicLen = 40 * 1024 * 1024;
m_strJpegWithAppendData.write();
bRet = hCNetSDK.NET_DVR_CaptureJPEGPicture_WithAppendData(lUserID, iChannelNum, m_strJpegWithAppendData);
if (bRet == true) {
m_strJpegWithAppendData.read();
log.info("NET_DVR_CaptureJPEGPicture_WithAppendData调用成功图片和温度数据已保存在pic文件夹中热成像有效区域{"
+ m_strJpegWithAppendData.struThermalValidRect.fX + "," + m_strJpegWithAppendData.struThermalValidRect.fY
+ "," + m_strJpegWithAppendData.struThermalValidRect.fWidth + "," + m_strJpegWithAppendData.struThermalValidRect.fHeight + "},可见光有效区域:{"
+ m_strJpegWithAppendData.struVisibleValidRect.fX + "," + m_strJpegWithAppendData.struVisibleValidRect.fY + "," + m_strJpegWithAppendData.struVisibleValidRect.fWidth
+ "," + m_strJpegWithAppendData.struVisibleValidRect.fHeight + "}");
//测温数据
if (m_strJpegWithAppendData.dwP2PDataLen > 0) {
SimpleDateFormat sf = new SimpleDateFormat("yyyymmddHHmmss");
String newName = sf.format(new Date());
File dir = new File(".\\pic\\");
if (!dir.exists()) {
dir.mkdir();
}
FileOutputStream fout;
BufferedWriter fout1;
try {
fout = new FileOutputStream(".\\pic\\" + "测温" + newName + ".data");
ByteBuffer bufferss = m_strJpegWithAppendData.pP2PDataBuff.getByteBuffer(0,
m_strJpegWithAppendData.dwP2PDataLen);
byte[] bytess = new byte[m_strJpegWithAppendData.dwP2PDataLen];
bufferss.rewind();
bufferss.get(bytess);
fout.write(bytess);
fout.close();
fout1 = new BufferedWriter(new FileWriter(dir + "\\测温" + newName + ".csv"));
String tempdata = "";
byte[] byTempData = new byte[4];
for (int i = 0; i < m_strJpegWithAppendData.dwJpegPicHeight; i++) {
for (int j = 0; j < m_strJpegWithAppendData.dwJpegPicWidth; j++) {
ByteBuffer TempDatabuffers =
m_strJpegWithAppendData.pP2PDataBuff.getByteBuffer((j + i * m_strJpegWithAppendData.dwJpegPicWidth) * 4, 4);
TempDatabuffers.get(byTempData);
int l;
l = byTempData[0];
l &= 0xff;
l |= ((long) byTempData[1] << 8);
l &= 0xffff;
l |= ((long) byTempData[2] << 16);
l &= 0xffffff;
l |= ((long) byTempData[3] << 24);
tempdata = " " + Float.intBitsToFloat(l);
fout1.write(tempdata);
fout1.write(",");
}
fout1.newLine();
}
fout1.close();
} catch (FileNotFoundException e) {
log.error("路径不存在");
} catch (IOException e) {
log.error("异常");
}
}
//测温图片
if (m_strJpegWithAppendData.dwJpegPicLen > 0) {
SimpleDateFormat sf = new SimpleDateFormat("yyyymmddHHmmss");
String newName = sf.format(new Date());
FileOutputStream pic;
FileOutputStream pic1;
FileOutputStream pic2;
try {
pic = new FileOutputStream(".\\pic\\" + "测温_T" + newName + ".jpg");
pic1 = new FileOutputStream(".\\pic\\" + "测温_T" + newName + ".data");
pic2 = new FileOutputStream(".\\pic\\" + "测温_V" + newName + ".jpg");
ByteBuffer buffers = m_strJpegWithAppendData.pJpegPicBuff.getByteBuffer(0,
m_strJpegWithAppendData.dwJpegPicLen);
ByteBuffer buffers1 = m_strJpegWithAppendData.pVisiblePicBuff.getByteBuffer(0,
m_strJpegWithAppendData.dwVisiblePicLen);
byte[] bytes = new byte[m_strJpegWithAppendData.dwJpegPicLen];
byte[] bytes1 = new byte[m_strJpegWithAppendData.dwVisiblePicLen];
buffers.rewind();
buffers.get(bytes);
buffers1.rewind();
buffers1.get(bytes1);
pic.write(bytes);
pic1.write(bytes);
pic2.write(bytes1);
pic.close();
pic1.close();
pic2.close();
} catch (FileNotFoundException e) {
log.error("路径不存在");
} catch (IOException e) {
log.error("异常");
}
}
} else {
log.error("抓图叠加温度信息失败,错误码" + hCNetSDK.NET_DVR_GetLastError());
}
}
public String[][] jpegWithAppendData1(int lUserID, int iChannelNum, String csvFilePath) {
boolean bRet = false;
HCNetSDK.NET_DVR_JPEGPICTURE_WITH_APPENDDATA m_strJpegWithAppendData =
new HCNetSDK.NET_DVR_JPEGPICTURE_WITH_APPENDDATA();
m_strJpegWithAppendData.dwSize = m_strJpegWithAppendData.size();
HCNetSDK.BYTE_ARRAY ptrJpegByte = new HCNetSDK.BYTE_ARRAY(4 * 1024 * 1024);
HCNetSDK.BYTE_ARRAY ptrP2PDataByte = new HCNetSDK.BYTE_ARRAY(2 * 1024 * 1024);
HCNetSDK.BYTE_ARRAY ptrVisiblePicByte = new HCNetSDK.BYTE_ARRAY(40 * 1024 * 1024);
m_strJpegWithAppendData.pJpegPicBuff = ptrJpegByte.getPointer();
m_strJpegWithAppendData.pP2PDataBuff = ptrP2PDataByte.getPointer();
m_strJpegWithAppendData.pVisiblePicBuff = ptrVisiblePicByte.getPointer();
m_strJpegWithAppendData.dwJpegPicLen = 4 * 1024 * 1024;
m_strJpegWithAppendData.dwP2PDataLen = 2 * 1024 * 1024;
m_strJpegWithAppendData.dwVisiblePicLen = 40 * 1024 * 1024;
m_strJpegWithAppendData.write();
bRet = hCNetSDK.NET_DVR_CaptureJPEGPicture_WithAppendData(lUserID, iChannelNum, m_strJpegWithAppendData);
if (bRet == true) {
m_strJpegWithAppendData.read();
log.error("NET_DVR_CaptureJPEGPicture_WithAppendData调用成功图片和温度数据已保存在pic文件夹中热成像有效区域{"
+ m_strJpegWithAppendData.struThermalValidRect.fX + "," + m_strJpegWithAppendData.struThermalValidRect.fY
+ "," + m_strJpegWithAppendData.struThermalValidRect.fWidth + "," + m_strJpegWithAppendData.struThermalValidRect.fHeight + "},可见光有效区域:{"
+ m_strJpegWithAppendData.struVisibleValidRect.fX + "," + m_strJpegWithAppendData.struVisibleValidRect.fY + "," + m_strJpegWithAppendData.struVisibleValidRect.fWidth
+ "," + m_strJpegWithAppendData.struVisibleValidRect.fHeight + "}");
//测温数据
if (m_strJpegWithAppendData.dwP2PDataLen > 0) {
//String csvFilePath
BufferedWriter fout1;
try {
csvFilePath = csvFilePath.replaceAll("jpg", "csv");
log.error(csvFilePath);
fout1 = new BufferedWriter(new FileWriter(csvFilePath));
String tempdata = "";
byte[] byTempData = new byte[4];
String[][] temp =
new String[m_strJpegWithAppendData
.dwJpegPicWidth][m_strJpegWithAppendData.dwJpegPicHeight];
for (int i = 0; i < m_strJpegWithAppendData.dwJpegPicHeight; i++) {
for (int j = 0; j < m_strJpegWithAppendData.dwJpegPicWidth; j++) {
ByteBuffer TempDatabuffers =
m_strJpegWithAppendData.pP2PDataBuff.getByteBuffer((j + i * m_strJpegWithAppendData.dwJpegPicWidth) * 4, 4);
TempDatabuffers.get(byTempData);
int l;
l = byTempData[0];
l &= 0xff;
l |= ((long) byTempData[1] << 8);
l &= 0xffff;
l |= ((long) byTempData[2] << 16);
l &= 0xffffff;
l |= ((long) byTempData[3] << 24);
tempdata = " " + Float.intBitsToFloat(l);
temp[j][i] = tempdata.trim();
fout1.write(tempdata);
fout1.write(",");
}
fout1.newLine();
}
fout1.close();
String hexFilePath = csvFilePath;
hexFilePath = hexFilePath.replaceAll("csv", "fir");
FileUtil.convertCsvToBinary(csvFilePath, hexFilePath);
return temp;
} catch (FileNotFoundException e) {
log.error("路径不存在");
} catch (IOException e) {
log.error("异常");
}
}
} else {
log.error("抓图叠加温度信息失败,错误码" + hCNetSDK.NET_DVR_GetLastError());
}
return null;
}
}

View File

@ -1,34 +0,0 @@
package com.yfd.platform.modules.deviceapi.Thermometry;
import com.sun.jna.ptr.IntByReference;
import com.yfd.platform.modules.deviceapi.HCNetSDK;
import java.text.DecimalFormat;
/**
* Created by panting6 on 2021/1/25.
*/
public class ThreadGetOnceTempData {
static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
public String threadGetOnceTempData(int lUserID, int RuleID) {
HCNetSDK.NET_DVR_THERMOMETRYRULE_TEMPERATURE_INFO m_TherTemInfo =
new HCNetSDK.NET_DVR_THERMOMETRYRULE_TEMPERATURE_INFO();
IntByReference lpBytesReturned = new IntByReference(0);
if (!hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_THERMOMETRYRULE_TEMPERATURE_INFO, RuleID,
m_TherTemInfo.getPointer(), 16 * 1024, lpBytesReturned)) {
return "";
} else {
m_TherTemInfo.read();
// 取小数点后一位
DecimalFormat format = new DecimalFormat("0.0");
float fMaxTemperature = m_TherTemInfo.fMaxTemperature;
float fMinTemperature = m_TherTemInfo.fMinTemperature;
String max = format.format(Double.valueOf(fMaxTemperature));
String min = format.format(Double.valueOf(fMinTemperature));
return max + "," + min;
}
}
}

View File

@ -1 +0,0 @@
The dll in this directory£¨iconv.dll,libxml2.dll,zlib1.dll,calib.dll£©only used in ClientDemo.