碰到问题如下:
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;
这样就解决了。
出现这种情况的原因为两种操作系统的中文压缩方式不同,在windows环境中中文压缩一般为gbk,而在linux环境中为utf8,这就导致了在windows下能正常显示。
解决方法:在linux用iconv命令,如乱码文件名为shujujiegou.txt,那么在终端输入如下命令:
sudo add-apt-repository ppa:no1wantdthisname/ppa
这句话的意思是获取最新的个人软件包档案源,将其添加至当前apt库中,并自动导入公钥
sudo apt update
sudo apt install libfreetype6
即可。
查看字体可以用下面的方法:
1. 打开 LibreOffice 查看
Ubuntu <wbr>12.04 <wbr>查看自带的中文字体
2. 终端中查看
终端中输入以下命令查看可用的中文字体:
fc-list :lang=zh-cn