Ubuntu OpenCV血泪史

Install OpenCV3 on Ubuntu
Raspbian Stretch: Install OpenCV 3 + Python on your Raspberry Pi
How to Install OpenCV on Ubuntu 18.04(Linuxize)

更换Ubuntu镜像(软件源)

Ubuntu 18.04更改apt为阿里云软件源(Linux公社)
清华源使用帮助
大佬博客:没有可用安装包

 以 Ubuntu 16.04 为例(可先备份)
 	 1.可以使用如下命令:
	sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
	2.直接编辑sudo /etc/apt/sources.list ,在文件最前面添加以下条目:
		sudo vim sources.list    # 在 /etc/apt 目录下
		ggdG    # 使用vim打开 sources.list 文件后执行此命令
	#默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
    deb https://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
    # deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial main main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
    # deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
    # deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
    # deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
     
    # 预发布软件源,不建议启用
    # deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
    # deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse

三行命令安装VMware tools

第一行命令: sudo apt-get upgrade
第二行命令: sudo apt-get install open-vm-tools-desktop -y
第三行命令: sudo reboot

更换pip源

How to Install Pip on Ubuntu 18.04(Linuxize)

git clone opencv遇到的问题

(蛋疼网速不要轻易尝试[😂],会有很多稀奇古怪的问题)

git clone https://github.com/opencv/opencv_contrib.git
正克隆到 'opencv_contrib'...
remote: Enumerating objects: 35, done.
remote: Counting objects: 100% (35/35), done.
remote: Compressing objects: 100% (32/32), done.
error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received.
fatal: The remote end hung up unexpectedly
fatal: 过早的文件结束符(EOF)
fatal: index-pack 失败

执行的错误的解决方案链接

git clone https://github.com/opencv/opencv_contrib.git 524288000正克隆到 '524288000'...
fatal: Out of memory, malloc failed (tried to allocate 524288000 bytes)

卸载软件
sudo apt-get autoremove --purge
sudo ———— 获取 root 权限
apt-get ——— 执行安装卸载功能的软件
autoremove — 告诉 apt-get 我们所要做的操作是移除软件
–purge ——— 注意这前面是两个短划线,这个参数是告诉他们要完整的干净的彻底的移除

Ubuntu解决没有可安装候选软件包

(源的问题很重要&关键!!!)

解决方法:可以使用apt-cache search <package_name>寻找。

例如:

E: 软件包 libqglviewer-dev 没有可安装候选

解决方法:

apt-cache search libqglviewer-dev
执行命令出现:

libqglviewer-dev-qt4 - OpenGL 3D viewer library based on Qt4 - development files
libqglviewer-dev-qt5 - OpenGL 3D viewer library based on Qt5 - development files
选择下面你要安装的软件包即可,我安装了第二个

sudo apt-get install libqglviewer-dev-qt5
最后就能完成替代了。

GDB的使用

1.进入GDB前生成debug文件
		lucas@ubuntu:~$ gcc -g -o  test.debug test.c 

2.进入GDB
		lucas@ubuntu:~$ gdb	
		GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
		Copyright (C) 2018 Free Software Foundation, Inc.
		License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
		This is free software: you are free to change and redistribute it.
		There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
		and "show warranty" for details.
		This GDB was configured as "x86_64-linux-gnu".
		Type "show configuration" for configuration details.
		For bug reporting instructions, please see:
		<http://www.gnu.org/software/gdb/bugs/>.
		Find the GDB manual and other documentation resources online at:
		<http://www.gnu.org/software/gdb/documentation/>.
		For help, type "help".
		Type "apropos word" to search for commands related to "word".

3.加载需要调试的程序
		(gdb) file test.debug 
		Reading symbols from test.debug...done.
		(gdb) list 1
		1	#include <stdio.h>
		2	
		3	int main()
		4	{
		5		printf("hahaha");
		6	
		7	
		8	}
		(gdb) 
		Line number 9 out of range; test.c has 8 lines.

4.显示第一个断点前的代码(继续摁enter键显示下一断点前代码)
		(gdb) list 1

5.
查看第一个断点
		(gdb) info breakpoint 1
查看所有断点
		(gdb) info breakpoints
		(gdb) info breakpoints 
		Num     Type           Disp Enb Address            What
		1       breakpoint     keep y   0x000000000000064e in main at test.c:5
		2       breakpoint     keep y   0x000000000000064e in main at test.c:5

6.在第3行增加一个断点
		(gdb) break 3
		Breakpoint 1 at 0x64e: file test.c, line 3.

7.开始调试程序
		(gdb) run
		Starting program: /home/lucas/test.debug 
		
		Breakpoint 1, main () at test.c:5
		5		printf("hahaha");

8.执行下一句		
		(gdb) next
		8	}

9.执行至下一个断点
		(gdb) continue 
		Continuing.
		hahaha[Inferior 1 (process 9835) exited normally]

8.帮助命令
		(gdb) help
		List of classes of commands:
				
		aliases -- Aliases of other commands
		breakpoints -- Making program stop at certain points
		data -- Examining data
		files -- Specifying and examining files
		internals -- Maintenance commands
		obscure -- Obscure features
		running -- Running the program
		stack -- Examining the stack
		status -- Status inquiries
		support -- Support facilities
		tracepoints -- Tracing of program execution without stopping the program
		user-defined -- User-defined commands
		
		Type "help" followed by a class name for a list of commands in that class.
		Type "help all" for the list of all commands.
		Type "help" followed by command name for full documentation.
		Type "apropos word" to search for commands related to "word".
		Command name abbreviations are allowed if unambiguous.

9.清除断点
		(gdb) clear
		已删除的多个断点 1 2 

10.退出调试
		(gdb) quit

Linux 下没有conio.h

原文

#include <stdio.h>
//#include <conio.h>

void main(){
char ch;
for(;😉{
// system(“stty -echo”);
ch = getch();
if(ch27) break;
if(ch
13)
continue;
putch(ch);
}
}

Linux实现conio.h中的getch()功能

在windows下写C程序时有时会用到conio.h这个头文件中的getch()功能,即读取键盘字符但是不显示出来(without echo)

后来发现含有conio.h的程序在linux无法编译通过,因为linux没有这个头文件,今天突然发现可以用其他方法代替,贴出来

//in windows

#include<stdio.h>

#include<conio.h>

int mian(){

char c;

printf(“input a char:”);

c=getch();

printf(“You have inputed:%c \n”,c);

return 0;

}

//in linux

#include<stdio.h>

int main(){

char c;

printf(“Input a char:”);

system(“stty -echo”);

c=getchar();

system(“stty echo”);

printf(“You have inputed:%c \n”,c);

return 0;

}

这样就可以了,注:linux中stty -echo是不显示输入内容的意思

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值