系统:Ubuntu18.04
Python版本:3.6.9(ubuntu18.04自带)
C++编辑器:code::blocks(ubuntu软件中可直接下载)
海康SDK版本:海康威视官网-服务支持-下载-SDK开发-设备网络SDK_Linux64(https://www.hikvision.com/cn/download_more_403.html)
我下载的版本是V6.1.6.45_build20210302
通过codeblocks新建动态链接库(File-New-Project-Shared library-Go-Next-C++-Next)
将main.cpp修改名称(看个人选择,可不修改)我修改为hkso.cpp
然后新建头文件 File - new -file-选择C/C++ header
根据自己的具体路径建立.hpp文件
在.hpp中添加如下代码
class Myceshi
{
void init(char* ip, char* usr, char* password);
void SetupAlarm();
char* SetMessageCallBack();
int get_num();
void CloseAlarm();
void release();
};
.cpp代码主要参考官方文档抓拍机那一篇的代码,代码过长,不再粘贴
配置环境
1.在codeblocks刚刚建立的工程下右键—Build options—Linker settings—linker libraries中添加海康SDK中的所有so文件(从官网下载的文件进行解压到我们建立工程的上级目录中)CH_HCNetSDK_Linux64/lib 以及CH_HCNetSDK_Linux64/lib/HCNetSDKCom下的所有so文件
2.在project – build option – search directories – Compiler中添加海康SDK头文件路径CH_HCNetSDK_Linux64/incCn
3.在project – build option – search directories – Linker中添加 /usr/local/lib路径
4.project – build option – Compiler settings – Other compiler options 添加 -fPIC
5.主界面 – Settings – Compiler settings – linker settings – linker libraries 添加 /usr/lib/x86_64-linux-gnu/libpthread.a 右边 other linker options 添加 -lpthread
6.将HKIPcamera动态链接库地址添加进系统路径
在/etc/ld.so.conf文件结尾添加网络sdk库的路径,如/XXX/CH_HCNetSDK_Linux64/lib和/XXX/CH_HCNetSDK_Linux64/lib/HCNetSDKCom/,保存之后,执行ldconfig
最后右键工程build或者rebuild,就会在工程目录下HKIPcamera/bin/Release或者Debug生成动态链接库文件
然后将so文件与测试的py放在同一目录下,就可以进行测试抓取车牌了
我所使用的海康官网版本以及我生成的so文件还有测试的py代码见链接https://download.csdn.net/download/qq_37754309/19777957