| | |
| | | <version>2.0.9</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <!--å¼ å»ºæä¾å¼å¯¼ä¾èµ--> |
| | | <dependency> |
| | | <groupId>org.gavaghan</groupId> |
| | | <artifactId>geodesy</artifactId> |
| | | <version>1.1.3</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.constant; |
| | | |
| | | /** |
| | | * @Description: sdkæ§å¶ä¼å
级 |
| | | * @ClassName: sdkPriority |
| | | * @Author: åèä¹ |
| | | * @Date: 2023å¹´05æ23æ¥11:25 |
| | | * @Version: 1.0 |
| | | **/ |
| | | public class sdkPriority { |
| | | static Integer radar_fire = 999; |
| | | } |
| | |
| | | Map<String,Double>ptzMap; |
| | | /*è¿æé´éï¼åéï¼*/ |
| | | Integer expired; |
| | | /*ç¸æºç»çº¬åº¦*/ |
| | | String camPosition; |
| | | /*ç®æ ç»çº¬åº¦*/ |
| | | String targetPosition; |
| | | } |
| | |
| | | return toAjax(sdk.setPtz(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("æåç®æ ") |
| | | @PostMapping("/setTargetPosition") |
| | | @Log(title = "æåç®æ ", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.channelNum", "cmd.targetPosition"}) |
| | | public @ResponseBody |
| | | AjaxResult setTargetPosition(@RequestBody CameraCmd cmd) { |
| | | return toAjax(sdk.setTargetPosition(cmd)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("è®¾ç½®é¶æ¹ä½è§") |
| | | @PostMapping("/setZeroPTZ") |
| | | @Log(title = "è®¾ç½®é¶æ¹ä½è§", businessType = BusinessType.CONTROL) |
| | |
| | | **/ |
| | | public interface hikClientService { |
| | | void loadHCNetSDKLib(); |
| | | |
| | | boolean setTargetPosition(CameraCmd cmd); |
| | | //ç»å½ |
| | | ArdCameras login(ArdCameras cameras); |
| | | |
| | |
| | | import com.ruoyi.device.camera.mapper.ArdCamerasMapper; |
| | | import com.ruoyi.device.hiksdk.common.global.globalVariable; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.camera.service.IArdCamerasService; |
| | | import com.ruoyi.device.cameracalibration.domain.ArdCamerasCalibration; |
| | | import com.ruoyi.device.hiksdk.domain.recordInfo; |
| | | import com.ruoyi.device.cameracalibration.service.IArdCamerasCalibrationService; |
| | | import com.ruoyi.device.hiksdk.util.hikSdkUtil.GisUtil; |
| | | import com.ruoyi.device.hiksdk.util.hikSdkUtil.HCNetSDK; |
| | | import com.ruoyi.device.hiksdk.service.hikClientService; |
| | | import com.ruoyi.device.hiksdk.util.imageUtil.waterMarkUtil; |
| | | import com.ruoyi.device.hiksdk.util.minioUtil.MinioUtil; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.sun.jna.Native; |
| | | import com.sun.jna.Platform; |
| | | import com.sun.jna.Pointer; |
| | |
| | | import sun.misc.BASE64Encoder; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.nio.ByteBuffer; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | * @ä¿®æ¹äººåå
¶å®ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @SdkOperate |
| | | // @SdkOperate |
| | | public boolean PTZControlWithSpeed(CameraCmd cmd) { |
| | | String cameraId = cmd.getCameraId(); |
| | | boolean enable = cmd.isEnable(); |
| | |
| | | } |
| | | return bool; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置èç¦å¼ |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean setTargetPosition(CameraCmd cmd) { |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer channelNum = cmd.getChannelNum(); |
| | | if (!globalVariable.loginMap.containsKey(cameraId)) { |
| | | return false; |
| | | } |
| | | Integer userId = globalVariable.loginMap.get(cameraId); |
| | | HCNetSDK.NET_DVR_PTZPOS m_ptzPosCurrent = new HCNetSDK.NET_DVR_PTZPOS(); |
| | | m_ptzPosCurrent.wAction = 1; |
| | | try { |
| | | double[] cameraPositon = Arrays.stream(cmd.getCamPosition().split(",")).mapToDouble(Double::parseDouble).toArray(); |
| | | double[] targetPositions = Arrays.stream(cmd.getTargetPosition().split(",")).mapToDouble(Double::parseDouble).toArray(); |
| | | double[] cameraPTZ = GisUtil.getCameraPTZ(cameraPositon, targetPositions, 20, 150); |
| | | String p = String.valueOf((int) ( cameraPTZ[0] * 10)); |
| | | String t = String.valueOf((int) ( cameraPTZ[1] * 10)); |
| | | String z = String.valueOf((int) (cameraPTZ[2]* 10)); |
| | | m_ptzPosCurrent.wPanPos = (short) (Integer.parseInt(p, 16)); |
| | | m_ptzPosCurrent.wTiltPos = (short) (Integer.parseInt(t, 16)); |
| | | m_ptzPosCurrent.wZoomPos = (short) (Integer.parseInt(z, 16)); |
| | | Pointer point = m_ptzPosCurrent.getPointer(); |
| | | m_ptzPosCurrent.write(); |
| | | boolean bool = hCNetSDK.NET_DVR_SetDVRConfig(userId, NET_DVR_SET_PTZPOS, channelNum, point, m_ptzPosCurrent.size()); |
| | | if (!bool) { |
| | | int code = hCNetSDK.NET_DVR_GetLastError(); |
| | | log.info("设置ptz失败,请ç¨åéè¯" + code); |
| | | } |
| | | return bool; |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage()); |
| | | return false; |
| | | } |
| | | } |
| | | /** |
| | | * @æè¿° ææ§éå® |
| | | * @åæ° [userId, channelNum] |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.hiksdk.util.hikSdkUtil; |
| | | |
| | | import org.gavaghan.geodesy.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | |
| | | public class GisUtil { |
| | | |
| | | public static GeodeticCalculator geodeticCalculator = new GeodeticCalculator(); |
| | | |
| | | /** |
| | | * æ ¹æ®ç»çº¬åº¦ï¼è®¡ç®ä¸¤ç¹é´çè·ç¦» |
| | | * |
| | | * @param longitudeFrom 第ä¸ä¸ªç¹çç»åº¦ |
| | | * @param latitudeFrom 第ä¸ä¸ªç¹ç纬度 |
| | | * @param longitudeTo 第äºä¸ªç¹çç»åº¦ |
| | | * @param latitudeTo 第äºä¸ªç¹ç纬度 |
| | | * @return è¿åè·ç¦» åä½ç±³ |
| | | */ |
| | | public static double getDistance(double longitudeFrom, double latitudeFrom, double longitudeTo, double latitudeTo) { |
| | | GlobalCoordinates source = new GlobalCoordinates(latitudeFrom, longitudeFrom); |
| | | GlobalCoordinates target = new GlobalCoordinates(latitudeTo, longitudeTo); |
| | | return geodeticCalculator.calculateGeodeticCurve(Ellipsoid.WGS84, source, target).getEllipsoidalDistance(); |
| | | } |
| | | |
| | | /** |
| | | * 计ç®ä»fromå°toæ¹åçç´çº¿ä¸æ£åæ¹åå¤¹è§ |
| | | * |
| | | * @param longitudeFrom 第ä¸ä¸ªç¹çç»åº¦ |
| | | * @param latitudeFrom 第ä¸ä¸ªç¹ç纬度 |
| | | * @param longitudeTo 第äºä¸ªç¹çç»åº¦ |
| | | * @param latitudeTo 第äºä¸ªç¹ç纬度 |
| | | * @return è¿åè§åº¦ |
| | | */ |
| | | public static double getNorthAngle(double longitudeFrom, double latitudeFrom, double longitudeTo, double latitudeTo) { |
| | | GlobalPosition source = new GlobalPosition(latitudeFrom, longitudeFrom, 0); |
| | | GlobalPosition target = new GlobalPosition(latitudeTo, longitudeTo, 0); |
| | | return geodeticCalculator.calculateGeodeticMeasurement(Ellipsoid.WGS84, source, target).getAzimuth(); |
| | | } |
| | | |
| | | /** |
| | | * @param camera ç»åº¦,纬度,é«åº¦ å¦:{125.097531, 46.60029, 120}; |
| | | * @param lookAt ç»åº¦,纬度,é«åº¦ å¦:{125.124731, 46.584808, 0}; |
| | | * @param viewAngle ç¸æºå¯è§è§åº¦ å¦:20 |
| | | * @param viewWidth è§å宽度 å¦:150 |
| | | * @return ptz æ°ç» å¦:[129.5355798969157, -2.5419097807416655, 23.3676043024458] |
| | | */ |
| | | public static double[] getCameraPTZ(double[] camera, double[] lookAt, double viewAngle, double viewWidth) { |
| | | double p = 0, t = 0, z = 0; |
| | | double distance = GisUtil.getDistance(camera[0], camera[1], lookAt[0], lookAt[1]); |
| | | double northAngle = GisUtil.getNorthAngle(camera[0], camera[1], lookAt[0], lookAt[1]); |
| | | double height = camera[2] - lookAt[2]; |
| | | p = northAngle; |
| | | t = Angle.toDegrees(Math.atan(height / distance)) * -1+360; |
| | | z = distance * Math.tan(viewAngle / 2) * 2 / viewWidth; |
| | | /* p = new BigDecimal(p).setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | t = new BigDecimal(t).setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | z = new BigDecimal(z).setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();*/ |
| | | return new double[]{p, t, z}; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // 125.097531,46.60029, 125.124731,46.584808 |
| | | //ç¸æºä½ç½® |
| | | double[] camera = {125.146964331147,46.5580925811216,102};//ç»åº¦,纬度,é«åº¦ |
| | | //çåçä½ç½® |
| | | double[] lookAt = {125.155449,46.555108,0};//ç»åº¦,纬度,é«åº¦ |
| | | |
| | | double viewAngle = 20;//ç¸æºå¯è§è§åº¦ |
| | | double viewWidth = 150;//ç¸æºè§å宽度 |
| | | |
| | | double[] ptz = GisUtil.getCameraPTZ(camera, lookAt, viewAngle, viewWidth); |
| | | System.out.println("ptz:" + Arrays.toString(ptz)); |
| | | |
| | | } |
| | | } |
| | |
| | | <link rel="stylesheet" th:href="@{/css/bootstrap.css}"/> |
| | | <script th:src="@{/js/bootstrap.js}"></script> |
| | | <style> |
| | | .top-buffer { margin-top:10px; } |
| | | .top-buffer { |
| | | margin-top: 10px; |
| | | } |
| | | </style> |
| | | <body> |
| | | <div class="container"> |
| | | <div class="row "> |
| | | <div class="dropdown"> |
| | | ç¸æºidï¼ |
| | | <select id="select"> |
| | | ç¸æºidï¼<select id="select"> |
| | | </select> |
| | | </div> |
| | | </div> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="row"> |
| | | <div class="col-md-6"> |
| | | <div class="row top-buffer"> |
| | | <div class="input-group"> |
| | | <span class="input-group-addon">ç®çåæ å¼ï¼</span> |
| | | <input id="targetPostion" class="form-control" placeholder="ç®çåæ "/> |
| | | <button id="setTargetPostion" type="button" class="btn btn-default">æååæ </button> |
| | | </div> |
| | | <div class="input-group"> |
| | | <span class="input-group-addon">På¼ï¼</span> |
| | | <input id="p" class="form-control" placeholder="请è¾å
¥På¼"/> |
| | |
| | | </div> |
| | | <div class="row top-buffer"> |
| | | <div class="col-md-6"> |
| | | <img class="thumbnail" id="imgContainer" style="width: 500px; height: 400px;padding: 5px 5px;"/> |
| | | </div> |
| | | <div class="col-md-6"> |
| | | <video id="video" muted autoplay loop controls style="width: 800px; height: 100%; object-fit: fill" /> |
| | | <img class="thumbnail" id="imgContainer" style="width: 500px; height: 300px;"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </body> |
| | | <div class="col-md-1"/> |
| | | <div class="col-md-5"> |
| | | <div class="row top-buffer"> |
| | | <video id="video" muted autoplay loop controls style="width: 800px; height: 100%; object-fit: fill;"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <script th:inline="javascript"> |
| | | var cameraId, opt, token; |
| | | window.onload = function () { |
| | |
| | | ipaddr: arr[i].ip, |
| | | username: arr[i].username, |
| | | password: arr[i].password, |
| | | port: arr[i].rtspPort |
| | | port: arr[i].rtspPort, |
| | | longitude: arr[i].longitude, |
| | | latitude: arr[i].latitude, |
| | | altitude: arr[i].altitude |
| | | }; |
| | | cameraMap.set(arr[i].id, camera); |
| | | //å
å建好selectéé¢çoptionå
ç´ |
| | |
| | | 'Authorization': token |
| | | }, |
| | | url: "../hik/setPTZ", |
| | | type: "post", |
| | | dataType: "json", |
| | | data: JSON.stringify(myEntity), |
| | | success: function (data) { |
| | | console.log(data); |
| | | } |
| | | }) |
| | | }) |
| | | $("#setTargetPostion").click(function () { |
| | | cameraId = $('#select option:selected').val(); |
| | | var camera = cameraMap.get(cameraId); |
| | | var camP = camera.longitude + ',' + camera.latitude + ',' + camera.altitude; |
| | | var targetP = $('#targetPostion').val(); |
| | | //å®ä¹ä¸ä¸ªå¸¦æMapåæ®µçå®ä½å¯¹è±¡ |
| | | var myEntity = { |
| | | channelNum: 1, |
| | | cameraId: cameraId, |
| | | targetPosition: targetP, |
| | | camPosition: camP, |
| | | }; |
| | | console.log(myEntity) |
| | | $.ajax({ |
| | | headers: { |
| | | 'Accept': 'application/json', |
| | | 'Content-Type': 'application/json', |
| | | 'Authorization': token |
| | | }, |
| | | url: "../hik/setTargetPosition", |
| | | type: "post", |
| | | dataType: "json", |
| | | data: JSON.stringify(myEntity), |
| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | let webRtcServer = null; |
| | | let videoMap = new Map(); |
| | | $('video').click(function (e) { |
| | |
| | | webRtcServer.disconnect(); |
| | | } |
| | | </script> |
| | | </body> |
| | | </html> |
| | |
| | | <link rel="stylesheet" th:href="@{/css/bootstrap.css}"/> |
| | | <script th:src="@{/js/bootstrap.js}"></script> |
| | | <style> |
| | | .top-buffer { margin-top:10px; } |
| | | .top-buffer { |
| | | margin-top: 10px; |
| | | } |
| | | </style> |
| | | <body> |
| | | <div class="container"> |
| | | <div class="row "> |
| | | <div class="dropdown"> |
| | | ç¸æºidï¼ |
| | | <select id="select"> |
| | | ç¸æºidï¼<select id="select"> |
| | | </select> |
| | | </div> |
| | | </div> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="row"> |
| | | <div class="col-md-6"> |
| | | <div class="row top-buffer"> |
| | | <div class="input-group"> |
| | | <span class="input-group-addon">ç®çåæ å¼ï¼</span> |
| | | <input id="targetPostion" class="form-control" placeholder="ç®çåæ "/> |
| | | <button id="setTargetPostion" type="button" class="btn btn-default">æååæ </button> |
| | | </div> |
| | | <div class="input-group"> |
| | | <span class="input-group-addon">På¼ï¼</span> |
| | | <input id="p" class="form-control" placeholder="请è¾å
¥På¼"/> |
| | |
| | | </div> |
| | | <div class="row top-buffer"> |
| | | <div class="col-md-6"> |
| | | <img class="thumbnail" id="imgContainer" style="width: 500px; height: 400px;padding: 5px 5px;"/> |
| | | </div> |
| | | <div class="col-md-6"> |
| | | <video id="video" muted autoplay loop controls style="width: 800px; height: 100%; object-fit: fill" /> |
| | | <img class="thumbnail" id="imgContainer" style="width: 500px; height: 300px;"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </body> |
| | | <div class="col-md-1"/> |
| | | <div class="col-md-5"> |
| | | <div class="row top-buffer"> |
| | | <video id="video" muted autoplay loop controls style="width: 800px; height: 100%; object-fit: fill;"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <script th:inline="javascript"> |
| | | var cameraId, opt, token; |
| | | window.onload = function () { |
| | |
| | | ipaddr: arr[i].ip, |
| | | username: arr[i].username, |
| | | password: arr[i].password, |
| | | port: arr[i].rtspPort |
| | | port: arr[i].rtspPort, |
| | | longitude: arr[i].longitude, |
| | | latitude: arr[i].latitude, |
| | | altitude: arr[i].altitude |
| | | }; |
| | | cameraMap.set(arr[i].id, camera); |
| | | //å
å建好selectéé¢çoptionå
ç´ |
| | |
| | | 'Authorization': token |
| | | }, |
| | | url: "../hik/setPTZ", |
| | | type: "post", |
| | | dataType: "json", |
| | | data: JSON.stringify(myEntity), |
| | | success: function (data) { |
| | | console.log(data); |
| | | } |
| | | }) |
| | | }) |
| | | $("#setTargetPostion").click(function () { |
| | | cameraId = $('#select option:selected').val(); |
| | | var camera = cameraMap.get(cameraId); |
| | | var camP = camera.longitude + ',' + camera.latitude + ',' + camera.altitude; |
| | | var targetP = $('#targetPostion').val(); |
| | | //å®ä¹ä¸ä¸ªå¸¦æMapåæ®µçå®ä½å¯¹è±¡ |
| | | var myEntity = { |
| | | channelNum: 1, |
| | | cameraId: cameraId, |
| | | targetPosition: targetP, |
| | | camPosition: camP, |
| | | }; |
| | | console.log(myEntity) |
| | | $.ajax({ |
| | | headers: { |
| | | 'Accept': 'application/json', |
| | | 'Content-Type': 'application/json', |
| | | 'Authorization': token |
| | | }, |
| | | url: "../hik/setTargetPosition", |
| | | type: "post", |
| | | dataType: "json", |
| | | data: JSON.stringify(myEntity), |
| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | let webRtcServer = null; |
| | | let videoMap = new Map(); |
| | | $('video').click(function (e) { |
| | |
| | | webRtcServer.disconnect(); |
| | | } |
| | | </script> |
| | | </body> |
| | | </html> |
| | |
| | | package com.ruoyi.framework.aspectj; |
| | | |
| | | import com.ruoyi.common.annotation.SdkOperate; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.camera.service.IArdCamerasService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Before; |
| | | import org.aspectj.lang.annotation.Pointcut; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * SDKæ§å¶å¤ç |
| | |
| | | |
| | | @Around("dsPointCut()") |
| | | public Object around(ProceedingJoinPoint point) throws Throwable { |
| | | |
| | | Boolean resultMap = dataScopeFilter(point); |
| | | if (resultMap) { |
| | | return point.proceed(); |
| | |
| | | * @param joinPoint åç¹ |
| | | */ |
| | | public Boolean dataScopeFilter(ProceedingJoinPoint joinPoint) { |
| | | |
| | | //è·åè¯·æ±æ§å¶ç¸æºçä¿¡æ¯ |
| | | CameraCmd cmd = (CameraCmd) joinPoint.getArgs()[0]; |
| | | ArdCameras ardCameras = ardCamerasService.selectArdCamerasById(cmd.getCameraId()); |
| | | if (StringUtils.isNull(ardCameras)) { |
| | | return false; |
| | | } |
| | | //ä¼å
级æ¯å¯¹ |
| | | Date operatorExpired = ardCameras.getOperatorExpired(); |
| | | Date now = new Date(); |
| | | if (now.before(operatorExpired)) { |
| | | //æªè¿æ |
| | | |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | if (StringUtils.isNull(loginUser)) { |
| | | return false;//å½åç»å½ç¨æ·ä¸ºç©ºä¸å¯ä»¥æ§å¶ |