search
HomeJavajavaTutorialHow to use Java Hikvision SDK for secondary development of custom functions
How to use Java Hikvision SDK for secondary development of custom functionsSep 06, 2023 am 09:28 AM
Secondary developmentKeywords: javaHaikang sdk

How to use Java Hikvision SDK for secondary development of custom functions

How to use Java Hikvision SDK for secondary development of custom functions

Introduction:
With the continuous advancement of technology, monitoring equipment has become more and more important in our lives. play an increasingly important role. As one of the leaders in domestic surveillance equipment, Hikvision’s SDK provides a powerful development platform, allowing developers to conduct secondary development according to their own needs. This article will introduce how to use Java Hikvision SDK for secondary development of custom functions, aiming to help developers better use Hikvision SDK for project development.

1. Introduction to Hikvision-Java-SDK
Hikvision-Java-SDK is a Java development toolkit provided by Hikvision to developers. It is mainly used to interact with and customize Hikvision devices. Functional development. Its core functions include real-time preview, video playback, PTZ control, device information acquisition, etc. By using Hikvision-Java-SDK, developers can easily communicate with Hikvision devices and implement customized functions.

2. Environment preparation

  1. JDK environment: Ensure that the Java development environment has been correctly installed and configured;
  2. Hikvision-Java-SDK: From Hikvision Download and install the latest version of Hikvision-Java-SDK from the official website (https://www.hikvision.com/);
  3. Development tools: It is recommended to use Java development tools such as IntelliJ IDEA.

3. Create a Java project and import the SDK

  1. Create a new Java project and open it with development tools;
  2. Place the downloaded Hikvision- Unzip the Java-SDK compressed package and copy the jar files to the lib folder of the project;
  3. Right-click the project in the development tool and select "Open Module Settings" to enter the project settings window;
  4. Select "Libraries" on the left side of the project settings window, then click the " " button in the upper right corner and select "Java";
  5. In the pop-up dialog box, select the lib folder and click "OK" to complete the import.

4. Sample Code
The following takes the real-time preview function of monitoring equipment as an example to demonstrate how to use Hikvision-Java-SDK to develop custom functions. Please follow the steps below:

  1. Create a new Java class named HikvisionUtils;
  2. Import the required packages in the SDK in the HikvisionUtils class, the example is as follows :

    import com.sun.jna.NativeLong;
    import com.sun.jna.Pointer;
    import com.sun.jna.ptr.IntByReference;
    import com.sun.jna.ptr.NativeLongByReference;
    import com.sun.jna.ptr.PointerByReference;
    import com.sun.jna.win32.StdCallLibrary;
    import com.sun.jna.win32.W32APIOptions;
  3. Define the function interface required in the SDK in the HikvisionUtils class. The example is as follows:

    public interface HCNetSDK extends StdCallLibrary {
     HCNetSDK INSTANCE = (HCNetSDK) Native.loadLibrary("HCNetSDK", HCNetSDK.class, new HashMap<String, Object>() {
         {put(OPTION_TYPE_MAPPER, W32APIOptions.UNICODE);}
     });
    
     boolean NET_DVR_Init();
     void NET_DVR_Cleanup();
     NativeLong NET_DVR_Login_V30(String sDVRIP, short wDVRPort, String sUserName, String sPassword, NET_DVR_DEVICEINFO_V30 lpDeviceInfo);
    }
  4. Implement real-time preview in the HikvisionUtils class Function, examples are as follows:

    public class HikvisionUtils {
     public static void main(String[] args) {
         // 初始化SDK
         HCNetSDK.INSTANCE.NET_DVR_Init();
    
         // 登录设备
         String ip = "192.168.1.100";
         int port = 8000;
         String username = "admin";
         String password = "123456";
         NET_DVR_DEVICEINFO_V30 deviceInfo = new NET_DVR_DEVICEINFO_V30();
         NativeLong userID = HCNetSDK.INSTANCE.NET_DVR_Login_V30(ip, (short) port, username, password, deviceInfo);
         if (userID.intValue() < 0) {
             System.out.println("登录失败");
         } else {
             System.out.println("登录成功");
    
             // 获取通道号
             int channelID = 1;
             
             // 创建预览参数
             NET_DVR_PREVIEWINFO previewInfo = new NET_DVR_PREVIEWINFO();
             previewInfo.lChannel = new NativeLong(channelID);
             previewInfo.dwStreamType = 0;  // 主码流
             previewInfo.dwLinkMode = 0x0000;  // TCP方式
             previewInfo.bBlocked = 1;  // 阻塞取流
    
             // 开始预览
             NativeLong playHandle = HCNetSDK.INSTANCE.NET_DVR_RealPlay_V30(userID, previewInfo, null, null, true);
             if (playHandle.intValue() < 0) {
                 System.out.println("预览失败");
             } else {
                 System.out.println("预览成功");
                 
                 // 此处可执行其他自定义功能的操作
                 
                 // 停止预览
                 HCNetSDK.INSTANCE.NET_DVR_StopRealPlay(playHandle);
             }
    
             // 注销登录
             HCNetSDK.INSTANCE.NET_DVR_Logout(userID);
         }
    
         // 释放SDK资源
         HCNetSDK.INSTANCE.NET_DVR_Cleanup();
     }
    }

5. Run the program
After completing the above steps, you can run the code in the HikvisionUtils class to realize the real-time preview function of the monitoring device. Before running the program, make sure that the device's IP address, port number, username, and password have been correctly configured.

6. Summary
Through the introduction of this article, we have learned how to use Java Hikvision SDK for secondary development of custom functions. Hikvision SDK provides rich functional interfaces and sample codes, and also supports secondary development for custom functions. I hope this article can help developers who are doing secondary development of Hikvision equipment. I also hope that everyone can have a deeper understanding of the development and application of monitoring equipment by reading this article.

The above is the detailed content of How to use Java Hikvision SDK for secondary development of custom functions. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
简单易懂的Java海康SDK二次开发指南简单易懂的Java海康SDK二次开发指南Sep 06, 2023 pm 02:01 PM

简单易懂的Java海康SDK二次开发指南引言:随着摄像监控技术的发展,海康威视已成为全球领先的安防解决方案供应商之一,其提供的SDK(软件开发工具包)为开发人员提供了丰富的功能和接口,用于二次开发和定制化开发。本文将介绍如何使用Java语言进行海康SDK的二次开发,并提供一些代码示例,以帮助读者更好地理解和应用。一、环境准备首先,在进行海康SDK二次开发之前

百度智能云千帆大模型平台再升级:5款大模型、55个工具组件上新!百度智能云千帆大模型平台再升级:5款大模型、55个工具组件上新!Mar 22, 2024 am 08:10 AM

服务8万企业用户,累计帮助用户精调1.3万个大模型,帮助用户开发出16万个大模型应用,自2023年12月以来百度智能云千帆大模型平台API日调用量环比增长97%...从一年前国内大模型平台的“开路先锋”到如今的大模型“超级工厂”,百度智能云千帆大模型平台在国内大模型市场牢牢占据着领先身位,但奔跑的脚步却并未停歇。3月21日,百度智能云在北京首钢园召开千帆产品发布会,百度智能云在大会期间宣布:1、携手北京市石景山区,共建全国首个百度智能云千帆大模型产业创新基地,助推区域产业腾飞;2、满足企业“效价

TensorFlow深度学习框架模型推理Pipeline进行人像抠图推理TensorFlow深度学习框架模型推理Pipeline进行人像抠图推理Mar 26, 2024 pm 01:00 PM

概述为了使ModelScope的用户能够快速、方便的使用平台提供的各类模型,提供了一套功能完备的Pythonlibrary,其中包含了ModelScope官方模型的实现,以及使用这些模型进行推理,finetune等任务所需的数据预处理,后处理,效果评估等功能相关的代码,同时也提供了简单易用的API,以及丰富的使用样例。通过调用library,用户可以只写短短的几行代码,就可以完成模型的推理、训练和评估等任务,也可以在此基础上快速进行二次开发,实现自己的创新想法。目前library提供的算法模型,

提升Java海康SDK二次开发技能的关键要素提升Java海康SDK二次开发技能的关键要素Sep 06, 2023 pm 01:42 PM

提升Java海康SDK二次开发技能的关键要素摘要:随着物联网的快速发展,视频监控系统在安防领域的应用越来越广泛。而作为视频监控系统中最重要的组成部分,海康威视(Hikvision)的SDK在二次开发过程中扮演着重要的角色。本文将介绍海康SDK的基本使用方法,并提供一些关键要素和代码示例,以帮助读者提升Java海康SDK二次开发技能。一、了解海康SDK的基本概

wordpress二次开发是什么意思wordpress二次开发是什么意思Apr 16, 2024 am 12:09 AM

WordPress 二次开发允许开发人员定制和扩展 WordPress 功能,创建满足特定需求的附加功能、主题和插件。通过二次开发,开发人员可以定制 WordPress,扩展其核心功能,增加其灵活性,并随着网站和业务的发展轻松扩展其可扩展性。

MyBatis逆向工程的优势与限制MyBatis逆向工程的优势与限制Feb 22, 2024 pm 07:27 PM

MyBatis是一种流行的持久化框架,它提供了逆向工程的功能,这使得开发人员可以根据数据库中的表结构自动生成实体类、Mapper接口和XML映射文件。逆向工程是MyBatis的一个重要特性,它可以大大减少开发人员的工作量,并提高代码的可维护性。然而,逆向工程也有一些限制,本文将介绍MyBatis逆向工程的优势和限制,并通过具体的代码示例加以说明。首先,让我们

WordPress是什么?详解这个流行的网站建设工具WordPress是什么?详解这个流行的网站建设工具Mar 04, 2024 pm 12:09 PM

WordPress是什么?详解这个流行的网站建设工具WordPress是一个开放源码的内容管理系统(CMS),最初是为博客而设计,但随着发展逐渐成为了全球最流行的网站建设工具之一。它使得网站的创建变得简单易行,不仅适用于个人博客,还广泛应用于企业网站、电子商务平台、新闻网站等各种类型的网站。作为一个开源软件,WordPress拥有一个强大的社区支持和全球化的

安卓系统究竟是不是基于Linux内核?安卓系统究竟是不是基于Linux内核?Mar 14, 2024 pm 03:12 PM

安卓系统究竟是不是基于Linux内核?安卓系统作为目前全球使用最广泛的移动操作系统之一,一直以来都被称为基于Linux内核开发的。然而,真正的情况究竟如何呢?我们来探讨一下这个问题。首先,让我们了解一下Linux内核。Linux内核作为一个开源的操作系统内核,是由LinusTorvalds于1991年首次发布的。它为许多操作系统提供了良好的基础,包括And

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!