win10 opencv 项目程序移植到 ubuntu16.04: 2.项目编译

xiaoxiao2021-02-28  104

碰到问题如下:

1、include <opencv2\opencv.hpp>

改成include <opencv2/opencv.hpp>

2、error: ‘to_string’ is not a member of ‘std’

g++后面加-std=c++11

因为:to_string is a C++11 feature. You may have to turn that on.

3、头文件区分大小写,最好把源码文件名都改成小写

4、 error: invalid initialization of non-const reference of type '    int&' from a temporary of type 'int'

是因为c++中临时变量不能作为非const的引用参数,所以void fun(const int &a) 加const即可。

5、运行时 libopencv_world.so no such file or directory

sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf' sudo ldconfig

6、运行代码时,在视频打开这里提示:opencv unable to stop the stream: inappropriate ioctl for device 

cmake-gui里选择安装:

WITH_PNG

WIHT_V4L

WIHT_JPEG

BUILD_opencv_world

7、opencv-jni -调试出错taking address of temporary [-fpermissive]

IplImage *qImg=&(IplImage)dst1;报错taking address of temporary [-fpermissive]

原来中 &(IplImage)dst1操作取了临时变量的地址。返回后临时变量已经“消失”了,你不能再使用了。所以报错。

解决方法:设置中间变量:

IplImage temp = (IplImage)dst1; IplImage *qImg=&temp;

这样就解决了。

8、linux下打开windows txt文件中文乱码问题

出现这种情况的原因为两种操作系统的中文压缩方式不同,在windows环境中中文压缩一般为gbk,而在linux环境中为utf8,这就导致了在windows下能正常显示。

解决方法:在linux用iconv命令,如乱码文件名为shujujiegou.txt,那么在终端输入如下命令:

[plain]  view plain  copy iconv -f gbk -t utf8 main.cpp > main.cpp.utf8   9、freetype安装: 可以不用源码编译,直接安装包安装 sudo add-apt-repository ppa:no1wantdthisname/ppa 这句话的意思是获取最新的个人软件包档案源,将其添加至当前apt库中,并自动导入公钥 sudo apt update sudo apt install libfreetype6 即可。 再makefile文件里加 -lfreetype 10、 汉字怎么弄都是中文中有空格 改用const wchar_t *msg=L"中文" 11、 查看 Ubuntu 16.04自带的中文字体  ubuntu 下自带的中文字体不多,只有微米黑的几种。 查看字体可以用下面的方法: 1. 打开 LibreOffice 查看 Ubuntu <wbr>12.04 <wbr>查看自带的中文字体 2. 终端中查看 终端中输入以下命令查看可用的中文字体: fc-list :lang=zh-cn

转载请注明原文地址: https://www.6miu.com/read-47989.html

最新回复(0)