| | |
| | | import com.ruoyi.alarm.global.domain.GuideTask; |
| | | import com.ruoyi.alarm.global.service.impl.QueueHandler; |
| | | import com.ruoyi.common.annotation.SdkOperate; |
| | | import com.ruoyi.common.config.ARDConfig; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.common.utils.file.MimeTypeUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.device.camera.factory.CameraSDK; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.camera.factory.CameraSDK; |
| | | import com.ruoyi.device.camera.service.IArdCamerasService; |
| | | import com.ruoyi.device.camera.service.ICameraSdkService; |
| | | import com.ruoyi.device.channel.domain.ArdChannel; |
| | | import com.ruoyi.device.channel.service.IArdChannelService; |
| | | import com.ruoyi.media.domain.Vtdu; |
| | | import com.ruoyi.media.service.IVtduService; |
| | | import com.ruoyi.utils.gis.GisUtil; |
| | | import com.ruoyi.utils.minio.MinioUtil; |
| | | import com.ruoyi.utils.sdk.common.GlobalVariable; |
| | | import com.ruoyi.utils.sdk.common.SdkErrorCodeEnum; |
| | | import com.ruoyi.utils.sdk.dhsdk.common.ErrorCode; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.NetSDKLib; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.ToolKits; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.enumeration.EM_NEW_CONFIG; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.enumeration.NET_EM_CFG_OPERATE_TYPE; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.structure.CFG_INFRARED_INFO; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.structure.CFG_VIDEO_IN_FOCUS; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.structure.DH_OUT_PTZ_VIEW_RANGE_STATUS; |
| | | import com.ruoyi.utils.sdk.dhsdk.module.*; |
| | | import com.sun.jna.Native; |
| | | import com.sun.jna.Pointer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.text.DecimalFormat; |
| | |
| | | import java.util.concurrent.PriorityBlockingQueue; |
| | | |
| | | import static com.ruoyi.utils.sdk.dhsdk.lib.NetSDKLib.*; |
| | | import static com.ruoyi.utils.sdk.dhsdk.lib.NetSDKLib.NET_DEVSTATE_PTZ_VIEW_RANGE; |
| | | import static com.ruoyi.utils.sdk.dhsdk.lib.NetSDKLib.NET_PTZ_ControlType.NET_PTZ_POINT_MOVE_CONTROL; |
| | | import static com.ruoyi.utils.sdk.dhsdk.lib.NetSDKLib.NET_PTZ_ControlType.NET_PTZ_POINT_SET_CONTROL; |
| | | import static com.ruoyi.utils.sdk.dhsdk.lib.ToolKits.getErrorCodePrint; |
| | |
| | | private IArdChannelService ardChannelService; |
| | | @Resource |
| | | private IVtduService vtduService; |
| | | |
| | | @Resource |
| | | ICameraSdkService cameraSdkService; |
| | | @Value("${minio.endpoint}") |
| | | private String minioEndPoint; |
| | | @Resource |
| | |
| | | // 网络连接恢复 |
| | | private static HaveReConnect haveReConnect = new HaveReConnect(); |
| | | |
| | | @PostConstruct |
| | | public void initSdk() { |
| | | log.info("初始化大华sdk"); |
| | | LoginModule.init(disConnect, haveReConnect); |
| | | } |
| | | |
| | | /** |
| | | * 登录 |
| | |
| | | @Override |
| | | public AjaxResult login(ArdCameras camera) { |
| | | try { |
| | | LoginModule.init(disConnect, haveReConnect); |
| | | NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex(); |
| | | NetSDKLib.LLong loginId = LoginModule.login(camera.getIp(), camera.getPort(), camera.getUsername(), camera.getPassword(), m_stDeviceInfo); |
| | | if (loginId.longValue() <= 0) { |
| | | camera.setChanNum(0); |
| | | camera.setLoginId(-1); |
| | | camera.setLoginId(-1l); |
| | | camera.setState("0"); |
| | | ardCamerasService.updateArdCameras(camera); |
| | | //删除管理通道 |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | log.error("设备[" + camera.getIp() + ":" + camera.getPort() + "]登录失败:" + getErrorCodePrint()); |
| | | log.warn("设备[" + camera.getIp() + ":" + camera.getPort() + "]登录失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError())); |
| | | } |
| | | if (GlobalVariable.loginMap.containsKey(camera.getId())) { |
| | | GlobalVariable.loginMap.remove(camera.getId()); |
| | | } |
| | | //删除管理通道 |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | log.debug("设备[" + camera.getIp() + ":" + camera.getPort() + "]登录成功:" + (int) loginId.longValue()); |
| | | camera.setState("1"); |
| | | camera.setChanNum(m_stDeviceInfo.byChanNum); |
| | | camera.setStartDChan(1); |
| | | camera.setLoginId((int) loginId.longValue()); |
| | | ardCamerasService.updateArdCameras(camera); |
| | | camera.setStartChan(1); |
| | | camera.setLoginId(loginId.longValue()); |
| | | GlobalVariable.loginMap.put(camera.getId(), loginId); |
| | | |
| | | //获取最新通道 |
| | | for (int i = 1; i < m_stDeviceInfo.byChanNum + 1; i++) { |
| | | ArdChannel channel = new ArdChannel(); |
| | | NetSDKLib.AV_CFG_ChannelName av_cfg_channelName = new NetSDKLib.AV_CFG_ChannelName(); |
| | | boolean b = ConfigModule.GetNewDevConfig(loginId, i - 1, CFG_CMD_CHANNELTITLE, av_cfg_channelName); |
| | | if (b) { |
| | | String chanName = ""; |
| | | try { |
| | | chanName = new String(av_cfg_channelName.szName, "GBK").trim(); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | channel.setName(chanName.equals("") ? "通道" + i : chanName); |
| | | } |
| | | channel.setDeviceId(camera.getId()); |
| | | channel.setChanNo(i); |
| | | ardChannelService.insertArdChannel(channel); |
| | | List<ArdChannel> ardChannelList = getChannels(camera); |
| | | if (ardChannelList.size() > 0) { |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | ardChannelList.stream().forEach(channel -> { |
| | | ardChannelService.insertArdChannel(channel); |
| | | }); |
| | | camera.setChannelList(ardChannelList); |
| | | //通道批量添加到流媒体 |
| | | batchAddVtdu(camera); |
| | | } |
| | | //配置到流媒体 |
| | | addVtdu(camera); |
| | | ardCamerasService.updateArdCameras(camera); |
| | | //创建引导队列 |
| | | createGuideQueue(camera); |
| | | //加入已登录设备集合 |
| | | GlobalVariable.loginedSet.add(camera); |
| | | return AjaxResult.success("设备登录成功"); |
| | | } catch (Exception ex) { |
| | | log.error("设备登录异常:" + ex.getMessage()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Async("loginExecutor") |
| | | @Async("globalExecutor") |
| | | public AjaxResult asyncLogin(ArdCameras camera) { |
| | | try { |
| | | LoginModule.init(disConnect, haveReConnect); |
| | | NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex(); |
| | | NetSDKLib.LLong loginId = LoginModule.login(camera.getIp(), camera.getPort(), camera.getUsername(), camera.getPassword(), m_stDeviceInfo); |
| | | if (loginId.longValue() <= 0) { |
| | | camera.setChanNum(0); |
| | | camera.setLoginId(-1); |
| | | camera.setLoginId(-1l); |
| | | camera.setState("0"); |
| | | ardCamerasService.updateArdCameras(camera); |
| | | //删除管理通道 |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | log.error("设备[" + camera.getIp() + ":" + camera.getPort() + "]登录失败:" + getErrorCodePrint()); |
| | | log.warn("设备[" + camera.getIp() + ":" + camera.getPort() + "]登录失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn(getErrorCodePrint()); |
| | | } |
| | | if (GlobalVariable.loginMap.containsKey(camera.getId())) { |
| | | GlobalVariable.loginMap.remove(camera.getId()); |
| | | } |
| | | //删除管理通道 |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | log.debug("设备[" + camera.getIp() + ":" + camera.getPort() + "]登录成功:" + loginId); |
| | | camera.setState("1"); |
| | | camera.setChanNum(m_stDeviceInfo.byChanNum); |
| | | camera.setStartDChan(1); |
| | | camera.setLoginId((int) loginId.longValue()); |
| | | camera.setStartChan(1); |
| | | camera.setLoginId(loginId.longValue()); |
| | | ardCamerasService.updateArdCameras(camera); |
| | | GlobalVariable.loginMap.put(camera.getId(), loginId); |
| | | |
| | | //获取最新通道 |
| | | for (int i = 1; i < m_stDeviceInfo.byChanNum + 1; i++) { |
| | | ArdChannel channel = new ArdChannel(); |
| | | NetSDKLib.AV_CFG_ChannelName av_cfg_channelName = new NetSDKLib.AV_CFG_ChannelName(); |
| | | boolean b = ConfigModule.GetNewDevConfig(loginId, i-1, CFG_CMD_CHANNELTITLE, av_cfg_channelName); |
| | | if (!b) { |
| | | log.error("获取配置失败,请稍后重试" + getErrorCodePrint()); |
| | | // return AjaxResult.warn(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError())); |
| | | } |
| | | String chanName = ""; |
| | | try { |
| | | chanName = new String(av_cfg_channelName.szName, "GBK").trim(); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | channel.setName(chanName.equals("") ? "通道" + i : chanName); |
| | | |
| | | channel.setDeviceId(camera.getId()); |
| | | channel.setChanNo(i); |
| | | ardChannelService.insertArdChannel(channel); |
| | | List<ArdChannel> ardChannelList = getChannels(camera); |
| | | if (ardChannelList.size() > 0) { |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | ardChannelList.stream().forEach(channel -> { |
| | | ardChannelService.insertArdChannel(channel); |
| | | }); |
| | | camera.setChannelList(ardChannelList); |
| | | //通道批量添加到流媒体 |
| | | batchAddVtdu(camera); |
| | | } |
| | | //配置到流媒体 |
| | | addVtdu(camera); |
| | | ardCamerasService.updateArdCameras(camera); |
| | | //创建引导队列 |
| | | createGuideQueue(camera); |
| | | //加入已登录设备集合 |
| | | GlobalVariable.loginedSet.add(camera); |
| | | return AjaxResult.success("登录成功"); |
| | | } catch (Exception ex) { |
| | | log.error("登录异常:" + ex.getMessage()); |
| | |
| | | } |
| | | } |
| | | |
| | | //添加到流媒体 |
| | | private void addVtdu(ArdCameras camera) { |
| | | for (int i = 1; i < camera.getChanNum() + 1; i++) { |
| | | String name = camera.getId() + "_" + i; |
| | | String rtspSource = "rtsp://" + camera.getUsername() + ":" + camera.getPassword() + "@" + camera.getIp() + ":" + camera.getRtspPort() + "/cam/realmonitor?channel=" + i + "&subtype=0"; |
| | | Vtdu vtdu = vtduService.selectVtduByName(name); |
| | | if (vtdu != null) { |
| | | vtduService.deleteVtduByName(name); |
| | | } |
| | | //添加到流媒体 |
| | | CameraCmd cmd = new CameraCmd(camera.getId(), i); |
| | | Map<String, Object> videoCompressionCfg = getVideoCompressionCfg(cmd); |
| | | vtdu = new Vtdu(); |
| | | if (videoCompressionCfg.get("videoEncType") != null) { |
| | | if (videoCompressionCfg.get("videoEncType").equals("标准h264")) { |
| | | vtdu.setIsCode("0");//默认不转码 |
| | | } else { |
| | | vtdu.setIsCode("1");//默认转码 |
| | | } |
| | | } else { |
| | | vtdu.setIsCode("0");//默认不转码 |
| | | } |
| | | vtdu.setRtspSource(rtspSource); |
| | | vtdu.setName(camera.getId() + "_" + i); |
| | | vtdu.setMode("1");//默认CPU软解码 |
| | | vtdu.setCameraId(camera.getId()); |
| | | vtduService.insertVtdu(vtdu); |
| | | } |
| | | //通道批量添加到流媒体 |
| | | public void batchAddVtdu(ArdCameras camera) { |
| | | camera.getChannelList().stream().forEach(channel -> { |
| | | vtduService.addChanToVtdu(camera, channel); |
| | | }); |
| | | } |
| | | |
| | | |
| | | //创建引导队列 |
| | | private void createGuideQueue(ArdCameras camera) { |
| | | if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) { |
| | | Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator(); |
| | | PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator); |
| | | GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue); |
| | | //启动队列处理器 |
| | | queueHandler.process(camera.getId()); |
| | | if (camera.getGdtype().equals("1")) { |
| | | if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) { |
| | | Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator(); |
| | | PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator); |
| | | GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue); |
| | | //启动队列处理器 |
| | | queueHandler.process(camera.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //获取通道 |
| | | public List<ArdChannel> getChannels(ArdCameras camera) { |
| | | if (camera.getLoginId() < 0) { |
| | | return new ArrayList<>(); |
| | | } |
| | | LLong loginId = new LLong(camera.getLoginId()); |
| | | List<ArdChannel> ardChannelList = new ArrayList<>(); |
| | | for (int i = 1; i < camera.getChanNum() + 1; i++) { |
| | | ArdChannel channel = new ArdChannel(); |
| | | String chanName = ConfigModule.getChannelName(loginId, i).trim(); |
| | | channel.setName(chanName.equals("") ? "通道" + i : chanName); |
| | | channel.setDeviceId(camera.getId()); |
| | | channel.setChanNo(i); |
| | | if (camera.getGdtype().equals("2")) { |
| | | //NVR过滤不在线的通道 |
| | | if (!ConfigModule.queryCameraState(loginId, camera.getChanNum(), i)) { |
| | | continue; |
| | | } |
| | | } |
| | | ardChannelList.add(channel); |
| | | } |
| | | return ardChannelList; |
| | | } |
| | | |
| | | /** |
| | |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | String imagePath = FileUtils.createFile("D:/LocalCaptureTemp/" + cameraId + ".jpeg"); |
| | | // 本地临时录像地址 |
| | | String tempPath = ARDConfig.getProfile() + Constants.LOCAL_RECORD_TEMP_PREFIX; |
| | | String imagePath = FileUtils.createFile(tempPath + "/" + cameraId + ".jpeg"); |
| | | fCaptureReceiveCB1 m_CaptureReceiveCB = new fCaptureReceiveCB1(imagePath); |
| | | CapturePictureModule.setSnapRevCallBack(m_CaptureReceiveCB); |
| | | boolean b = CapturePictureModule.remoteCapturePicture(loginId, chanNo - 1); |
| | |
| | | @Override |
| | | public AjaxResult localRecordStart(CameraCmd cmd) { |
| | | try { |
| | | String operator = cmd.getOperator(); |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | |
| | |
| | | // GlobalVariable.previewMap.remove(cameraId); |
| | | // log.debug("停止当前录像"); |
| | | //} |
| | | String path = FileUtils.createFile("D:/LocalRecordTemp/" + cameraId + ".mp4"); |
| | | |
| | | // 本地临时录像地址 |
| | | String tempPath = ARDConfig.getProfile() + Constants.LOCAL_RECORD_TEMP_PREFIX; |
| | | String path = FileUtils.createFile(tempPath + "/" + operator + "/" + cameraId + ".mp4"); |
| | | LLong lRealHandle = RealPlayModule.startRealPlay(loginId, chanNo - 1, path); |
| | | if (lRealHandle.longValue() <= 0) { |
| | | log.error("取流失败" + getErrorCodePrint()); |
| | |
| | | @Override |
| | | public AjaxResult localRecordStop(CameraCmd cmd) { |
| | | try { |
| | | String operator = cmd.getOperator(); |
| | | String cameraId = cmd.getCameraId(); |
| | | LLong lRealHandle = new LLong(cmd.getRecordId()); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | |
| | | RealPlayModule.stopRealPlay(lRealHandle); |
| | | log.debug("本地录像停止"); |
| | | String recordPath = FileUtils.createFile("D:/LocalRecordTemp/" + cameraId + ".mp4"); |
| | | // 本地临时录像地址 |
| | | String tempPath = ARDConfig.getProfile() + Constants.LOCAL_RECORD_TEMP_PREFIX; |
| | | String recordPath = FileUtils.createFile(tempPath + "/" + operator + "/" + cameraId + ".mp4"); |
| | | byte[] imageBytes = Files.readAllBytes(Paths.get(recordPath)); |
| | | // OutputStream outputStream = response.getOutputStream(); |
| | | // outputStream.write(imageBytes); |
| | | return AjaxResult.success(imageBytes); |
| | | //if (GlobalVariable.previewMap.containsKey(cameraId)) { |
| | | // lRealHandle = new LLong(GlobalVariable.previewMap.get(cameraId)); |
| | | // RealPlayModule.stopRealPlay(lRealHandle); |
| | | // GlobalVariable.previewMap.remove(cameraId); |
| | | // log.debug("本地录像停止"); |
| | | // String recordPath = FileUtils.createFile("D:/LocalRecordTemp/" + cameraId + ".mp4"); |
| | | // byte[] imageBytes = Files.readAllBytes(Paths.get(recordPath)); |
| | | // // OutputStream outputStream = response.getOutputStream(); |
| | | // // outputStream.write(imageBytes); |
| | | // return AjaxResult.success(imageBytes); |
| | | //} |
| | | //else { |
| | | // return AjaxResult.error("设备未开始录像"); |
| | | //} |
| | | } catch (Exception ex) { |
| | | log.error("本地录像停止异常" + ex.getMessage()); |
| | | return AjaxResult.error("本地录像停止异常" + ex.getMessage()); |
| | |
| | | String url = ""; |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4"); |
| | | // 本地临时录像地址 |
| | | String tempPath = ARDConfig.getProfile() + Constants.LOCAL_RECORD_TEMP_PREFIX; |
| | | String path = FileUtils.createFile(tempPath + "/" + cameraId + ".mp4"); |
| | | boolean enable = cmd.isEnable(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return ""; |
| | |
| | | GlobalVariable.previewMap.remove(cameraId); |
| | | } |
| | | log.debug("录像停止"); |
| | | //存入minio |
| | | String BucketName = "record"; |
| | | String ObjectName = IdUtils.fastSimpleUUID() + ".mp4"; |
| | | FileInputStream stream = new FileInputStream(path); |
| | | boolean b = MinioUtil.uploadObject(BucketName, ObjectName, stream, stream.available(), "video/MP4"); |
| | | if (b) { |
| | | url = MinioUtil.getBucketObjectUrl(BucketName, ObjectName); |
| | | log.debug("上传文件成功!" + url); |
| | | } |
| | | } |
| | | return url; |
| | | } catch (Exception ex) { |
| | |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4"); |
| | | // 本地临时录像地址 |
| | | String tempPath = ARDConfig.getProfile() + Constants.LOCAL_RECORD_TEMP_PREFIX; |
| | | String path = FileUtils.createFile(tempPath + "/" + cameraId + ".mp4"); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return false; |
| | | } |
| | |
| | | String url = ""; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4"); |
| | | // 本地临时录像地址 |
| | | String tempPath = ARDConfig.getProfile() + Constants.LOCAL_RECORD_TEMP_PREFIX; |
| | | String path = FileUtils.createFile(tempPath + "/" + cameraId + ".mp4"); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return ""; |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<ArdChannel> getIPChannelInfo(ArdCameras camera) { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 引导目标位置 |
| | |
| | | double[] cameraPositon = new double[]{cameras.getLongitude(), cameras.getLatitude(), cameras.getAltitude()}; |
| | | double[] targetPositions = cmd.getTargetPosition(); |
| | | double[] cameraPTZ = GisUtil.getCameraPTZ(cameraPositon, targetPositions, 20, 150); |
| | | //修正俯仰 |
| | | double correctPitch = cameraSdkService.correctPitch(cmd); |
| | | double newt = cameraPTZ[1] + correctPitch; |
| | | int p = (int) (cameraPTZ[0] * 10); |
| | | int t = (int) (cameraPTZ[1] * 10); |
| | | int t = (int) (newt * 10); |
| | | int z = (int) (cameraPTZ[2]); |
| | | boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_EXACTGOTO, p, t, z, 0); |
| | | if (!bool) { |
| | | log.error("设置ptz失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("设置ptz失败:" + getErrorCodePrint()); |
| | | } |
| | | return AjaxResult.success("引导目标位置成功"); |
| | | return AjaxResult.success("引导目标位置成功", correctPitch); |
| | | } catch (Exception ex) { |
| | | log.error("引导目标位置异常:" + ex.getMessage()); |
| | | return AjaxResult.error("引导目标位置异常:" + ex.getMessage()); |