opencv交叉编译挺坑的,分享一下个人编译好的库
包含适用于 PC端 A7架构(V3s/V3X H2 H3等) A53架构(H5 H6)的opencv动态库
链接:
https://pan.baidu.com/s/19ia2QO9gtlHLV82U27WCmg
提取码:7ur9
【PC端】
将PC opencv和ARM opencv库解压到自定义路径下(PC用于调试,调试后成功后切换arm编译)
【ARM端】
将lib文件下的所有文件复制到板子/usr/lib下 (如果在arm端编译还需复制include下的文件)
【Qt】
INCLUDEPATH += /usr/local/include \
/usr/local/arm_opencv/include/opencv \
/usr/local/arm_opencv/include/opencv2
LIBS += /usr/local/arm_opencv/lib/libopencv*.so
【GCC】
g++ test.cpp -o test -I/home/lzq/opencv/PC_opencv/include -L/home/lzq/opencv/PC_opencv/lib -lopencv_highgui -lopencv_imgproc -lopencv_core -lopencv_imgcodecs -lopencv_videoio -lpthread -ldl
离线
网盘中人脸检测demo(使用usb摄像头)
全志V3X(128M内存)1帧速率(800ms一次)
全志H3(1G内存) 5帧速率(200ms一次)
离线
把文件复制到小电脑后,人脸识别demo也要复制到小电脑上,然后直接用这两个命令就行了吗?之后就可以用人脸识别了?
还需要在Qt里编译
离线
opencv图传
服务端
#include <unistd.h>//Linux系统下网络通讯的头文件集合
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <malloc.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <stdarg.h>
#include <fcntl.h>
#include <fcntl.h>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
using namespace std;
enum
{
PORT = 8888
};
int main(int argc, char** argv)
{
int m_sockClient;
if ((m_sockClient = socket(AF_INET, SOCK_DGRAM, 0)) < 0) //创建socket句柄,采用UDP协议
{
printf("create socket error: %s(errno: %d)\n", strerror(errno), errno);
return -1;
}
sockaddr_in m_servaddr;
memset(&m_servaddr, 0, sizeof(m_servaddr)); //初始化结构体
m_servaddr.sin_family = AF_INET; //设置通信方式
m_servaddr.sin_port = htons(PORT); //设置端口号
m_servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
int len = sizeof(m_servaddr);
bind(m_sockClient, (sockaddr*)&m_servaddr, sizeof(m_servaddr));//绑定套接字
Mat image;
unsigned char buf[426672];
struct sockaddr_in addr_client;
while (true)
{
std::vector<uchar> decode;
int n = recvfrom(m_sockClient, buf, sizeof(buf), 0,(struct sockaddr *)&addr_client, (socklen_t *)&len);//接受缓存
int pos = 0;
while (pos < n)
{
decode.push_back(buf[pos++]);//存入vector
}
buf[n] = 0;
image = imdecode(decode, CV_LOAD_IMAGE_COLOR);//图像解码
imshow("image", image);
waitKey(10);
}
return 0;
}
客户端
#include <unistd.h>//Linux系统下网络通讯的头文件集合
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <malloc.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <stdarg.h>
#include <fcntl.h>
#include <fcntl.h>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
using namespace std;
enum
{
PORT = 8888
};
int main(int argc, char** argv)
{
int m_sockClient;
if ((m_sockClient = socket(AF_INET, SOCK_DGRAM, 0)) < 0) //创建socket句柄,采用UDP协议
{
printf("create socket error: %s(errno: %d)\n", strerror(errno), errno);
return -1;
}
sockaddr_in m_servaddr;
memset(&m_servaddr, 0, sizeof(m_servaddr)); //初始化结构体
m_servaddr.sin_family = AF_INET; //设置通信方式
m_servaddr.sin_port = htons(PORT); //设置端口号
m_servaddr.sin_addr.s_addr = inet_addr(argv[1]);
//m_servaddr.sin_port = htons(8888);//设置需要发送的IP和端口号
bind(m_sockClient, (sockaddr*)&m_servaddr, sizeof(m_servaddr));//绑定端口号
VideoCapture capture(cv::String("/dev/video0"));//打开摄像头
Mat image;
while (true)
{
capture >> image;//读入图片
if (image.empty()) //如果照片为空则退出
{
printf("empty image\n\n");
return -1;
}
std::vector<uchar> data_encode;
std::vector<int> quality;
quality.push_back(CV_IMWRITE_JPEG_QUALITY);
quality.push_back(10);//进行50%的压缩
imencode(".jpg", image, data_encode,quality);//将图像编码
//char encodeImg[426672];
int nSize = data_encode.size();
unsigned char *encodeImg = new unsigned char[nSize];
printf("%d\n", nSize);
for (int i = 0; i < nSize; i++)
{
encodeImg[i] = data_encode[i];
}
sendto(m_sockClient, encodeImg, nSize, 0, (const sockaddr*)& m_servaddr, sizeof(m_servaddr));
memset(&encodeImg, 0, sizeof(encodeImg)); //初始化结构体
}
return 0;
}
离线