Home Java javaTutorial Advanced Java Hikvision SDK Secondary Development Technical Guide

Advanced Java Hikvision SDK Secondary Development Technical Guide

Sep 06, 2023 am 11:22 AM
advanced java Haikang sdk Secondary development technical guide

Advanced Java Hikvision SDK Secondary Development Technical Guide

Advanced Java Hikvision SDK Secondary Development Technical Guide

Introduction:
With the development of technology and the continuous expansion of application scenarios, video surveillance systems have gradually become an integral part of modern society. In the market, Hikvision's products have always been in a leading position, providing a series of high-quality video surveillance solutions. However, for some special needs, relying solely on native functions may not be able to meet them, which requires secondary development of Hikvision SDK. This article will focus on the advanced Java Hikvision SDK secondary development technology and give corresponding code examples.

1. SDK download and installation

  1. Go to Hikvision official website and find the SDK download page. According to your needs, select the corresponding SDK version and click to download.
  2. After the download is completed, unzip the file to the local directory.
  3. Import SDK into Java development tools.

2. SDK environment configuration

  1. Create a new Java project in the development tool.
  2. Add the jar package in the SDK to the project's dependencies.
  3. Configure JVM parameters and add the corresponding dynamic link library path.

3. SDK Initialization and Login
Before secondary development, we need to initialize and log in to the SDK to obtain the corresponding operating permissions.

import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.hikvision.netsdk.HCNetSDK;

public class SDKDemo {
    private static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;

    public static void main(String[] args) {
        // SDK初始化
        boolean initSuc = hCNetSDK.NET_DVR_Init();
        if (initSuc != true) {
            System.out.println("SDK初始化失败!");
            return;
        }

        // 登录
        HCNetSDK.NET_DVR_DEVICEINFO_V30 deviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V30();
        NativeLong lUserId = hCNetSDK.NET_DVR_Login_V30("192.168.1.100", (short) 8000,
                "admin", "password", deviceInfo);
        if (lUserId.longValue() < 0) {
            System.out.println("登录失败:" + hCNetSDK.NET_DVR_GetLastError());
            return;
        }

        // 登出
        boolean logoutSuc = hCNetSDK.NET_DVR_Logout(lUserId);
        if (logoutSuc != true) {
            System.out.println("登出失败:" + hCNetSDK.NET_DVR_GetLastError());
            return;
        }

        // SDK反初始化
        boolean cleanupSuc = hCNetSDK.NET_DVR_Cleanup();
        if (cleanupSuc != true) {
            System.out.println("SDK反初始化失败!");
            return;
        }
    }
}
Copy after login

4. Video Preview
This section will introduce how to perform video preview operations and show how to set up a callback function to obtain video data in real time.

import com.sun.jna.CallbackThreadInitializer;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.hikvision.netsdk.*;

public class SDKDemo {
    private static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;

    public static void main(String[] args) {
        // SDK初始化...

        // 登录...

        // 实时预览
        NativeLong lRealPlayHandle = hCNetSDK.NET_DVR_RealPlay_V30(lUserId, deviceInfo.byStartChan, null, null, true);
        if (lRealPlayHandle.longValue() < 0) {
            System.out.println("实时预览失败:" + hCNetSDK.NET_DVR_GetLastError());
            return;
        }

        // 设置预览回调函数
        HCNetSDK.FRealDataCallBack fRealDataCallBack = new HCNetSDK.FRealDataCallBack() {
            public void invoke(NativeLong lRealHandle, int dwDataType, Pointer pBuffer, int dwBufSize, Pointer pUser) {
                if (dwDataType == HCNetSDK.NET_DVR_SYSHEAD) {
                    // 获取系统头数据
                    System.out.println("收到系统头数据");
                } else if (dwDataType == HCNetSDK.NET_DVR_STREAMDATA) {
                    // 获取流数据
                    byte[] data = pBuffer.getByteArray(0, dwBufSize);
                    System.out.println("接收到视频数据:" + data.length);
                }
            }
        };

        boolean setCallbackSuc = hCNetSDK.NET_DVR_SetRealDataCallBack(lRealPlayHandle, fRealDataCallBack, null);
        if (setCallbackSuc != true) {
            System.out.println("设置预览回调函数失败:" + hCNetSDK.NET_DVR_GetLastError());
            return;
        }
        
        // 停止预览
        boolean stopPlaySuc = hCNetSDK.NET_DVR_StopRealPlay(lRealPlayHandle);
        if (stopPlaySuc != true) {
            System.out.println("停止预览失败:" + hCNetSDK.NET_DVR_GetLastError());
            return;
        }

        // 登出...

        // SDK反初始化...
    }
}
Copy after login

Conclusion:
The above is an introduction to the advanced Java Hikvision SDK secondary development technology. Through the implementation of SDK initialization, login, video preview and other operations, more personalized functional requirements can be realized. I hope this article will be helpful to developers who want to carry out secondary development of Hikvision SDK.

The above is the detailed content of Advanced Java Hikvision SDK Secondary Development Technical Guide. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

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)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Simple and easy-to-understand Java Hikvision SDK secondary development guide Simple and easy-to-understand Java Hikvision SDK secondary development guide Sep 06, 2023 pm 02:01 PM

Simple and easy-to-understand Java Hikvision SDK secondary development guide Introduction: With the development of camera surveillance technology, Hikvision has become one of the world's leading security solution providers. The SDK (software development kit) it provides is Developers provide a wealth of functions and interfaces for secondary development and customized development. This article will introduce how to use Java language for secondary development of Hikvision SDK, and provide some code examples to help readers better understand and apply. 1. Environment preparation First, before carrying out secondary development of Hikvision SDK

Key elements to improve secondary development skills of Java Hikvision SDK Key elements to improve secondary development skills of Java Hikvision SDK Sep 06, 2023 pm 01:42 PM

Summary of key elements to improve Java Hikvision SDK secondary development skills: With the rapid development of the Internet of Things, video surveillance systems are increasingly used in the security field. As the most important component of the video surveillance system, Hikvision’s SDK plays an important role in the secondary development process. This article will introduce the basic usage of Hikvision SDK and provide some key elements and code examples to help readers improve their Java Hikvision SDK secondary development skills. 1. Understand the basic overview of Hikvision SDK

Use Java Hikvision SDK secondary development to build a powerful video surveillance system Use Java Hikvision SDK secondary development to build a powerful video surveillance system Sep 06, 2023 pm 12:37 PM

Use Java Hikvision SDK for secondary development to build a powerful video surveillance system. Abstract: This article will introduce how to use Java Hikvision SDK for secondary development to build a powerful video surveillance system. Through the rich interfaces and functions provided by Hikvision SDK, we can easily implement video recording, real-time preview, remote control and other functions, and add customized business logic. This article will introduce in detail how to use Java Hikvision SDK for secondary development, and provide some sample code to help readers better understand. Part One: Environmental Standards

A highly customizable solution in the secondary development of Java Hikvision SDK A highly customizable solution in the secondary development of Java Hikvision SDK Sep 06, 2023 am 10:12 AM

A highly customizable solution for the secondary development of Java Hikvision SDK Summary: In modern monitoring systems, Hikvision SDK is one of the most commonly used development frameworks. This article will introduce how to conduct secondary development based on Java language and Hikvision SDK to achieve highly customizable solutions. At the same time, the article will also provide some code examples to help readers better understand the implementation process. 1. Introduction With the rapid development of the Internet and the Internet of Things, the application scope of monitoring systems is becoming more and more extensive. Hikvision SDK is currently the most popular software on the market.

Solutions to common problems in secondary development of Java Hikvision SDK Solutions to common problems in secondary development of Java Hikvision SDK Sep 06, 2023 pm 01:07 PM

Solutions to common problems in secondary development of Java Hikvision SDK 1. Introduction With the development of Internet of Things technology, video surveillance systems have become an important means of security protection in modern society. In the development process of video surveillance systems, Hikvision SDK is often widely used. However, during use, we often encounter some common problems. This article will introduce you step by step and provide solutions. 2. Question 1: SDK import problem In secondary development, the first problem is how to correctly import Hikvision SDK. The following are some common

Best practices for implementing secondary development functions of Java Hikvision SDK Best practices for implementing secondary development functions of Java Hikvision SDK Sep 06, 2023 am 10:19 AM

Introduction to the best practices for implementing the secondary development functions of Java Hikvision SDK: With the development of Internet of Things technology, the application of video surveillance systems is becoming more and more widespread. Hikvision is the world's leading provider of security products and solutions. Its Hikvision SDK provides a wealth of functions and interfaces to facilitate developers for secondary development. This article will introduce how to use Java language to implement the secondary development function of Hikvision SDK and provide corresponding code examples. 1. Environment preparation Before starting, we need to prepare the following environment: JDK1.8 and above

Best practices in secondary development of Java Hikvision SDK Best practices in secondary development of Java Hikvision SDK Sep 06, 2023 am 09:04 AM

Summary of best practices in secondary development of Java Hikvision SDK: With the widespread application of modern monitoring technology, the SDK (software development kit) provided by Hikvision has become the first choice for many developers. This article will introduce the best practices in secondary development of Java Hikvision SDK and provide some code examples. Before connecting the device to use Hikvision SDK, you first need to connect the device you want to operate. Here is a sample code to connect the device: importcom.sun.jna.NativeLong;imp

How to use Java Hikvision SDK for secondary development of custom functions How to use Java Hikvision SDK for secondary development of custom functions Sep 06, 2023 am 09:28 AM

How to use Java Hikvision SDK for secondary development of custom functions Introduction: With the continuous advancement of technology, monitoring equipment plays an increasingly important role in our lives. 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. Hikvisio

See all articles