虽然opencv3是基于opencv2进行开发的(一部分opencv2代码在opencv3中还能正常运行),但opencv3自身也做了部分修改,而目前网上很多教程还是基于opencv2的函数API来编写的,这导致在使用opencv3时会遇到各种函数未定义之类的问题。因而,为了方便今后查阅,同时避免更多人踩坑,在此总结一下opencv3相对于opencv2的改动之处。


opencv3中取消了旧版本中的"cv_"前缀命名,并使用了新的命名规范,主要分为以下几类:

(1)直接去掉"CV_"前缀

  • namedWindow函数,将cv_WINDOW_AUTOSIZE改为WINDOW_AUTOSIZE
  • line函数及其同一类的绘图函数,cv_filed改为filled
  • threshold函数,cv_thresh_binary改为thresh_binary
  • remap函数,cv_inter_linear改为inter_linear
  • 鼠标操作函数setmousecallback,将cv_event_lbuttonup改为event_lbuttonup,其他类似。
  • imwrite写图片函数,将cv_inpaint_telea改为inpaint_telea,cv_inpaint_ns改为inpaint_ns
  • 设置摄像头尺寸时将cv_cap_prop_frame_width改为cap_prop_frame_width,cv_cap_prop_frame_height 改为 cap_prop_frame_height

..等等一些函数可以直接将"cv_"前缀去除。

(2)需要新的前缀

  • line函数中一些绘函数中的参数,cv_AA改为LINE_AA
  • cvtColor函数中颜色转换系的宏,全替换为"COLOR_"前缀,如CV_BGR2HSV改为COLOR_BGR2HSV
  • normalize函数,将cv_MINMAX改为NORM_MINMAX 等等

(3)其他

  • 定义尺寸时将cvSize(-1,-1)改为Size(-1,-1)
  • 在表示颜色时,将cv_RGB改为Scalar。
  • 设置视频格式的fourcc,cv2.x版本中中形式为cv2.cv.fourcc,在cv3,0以上的版本中应为cv2.VideoWriter_fourcc,需要特别注意。

关于fourcc函数,真是大坑,各种搜索后才知道,原来函数名改了(⊙o⊙)

Reprinted from: http://blog.csdn.net/cike14/article/details/50627857

 
 
 
 

解决opencv3运行opencv2代码时报错的修改备忘录的更多相关文章

  1. 运行TensorFlow代码时报错

    运行TensorFlow代码时报错 错误信息ImportError: libcublas.so.10.0: cannot open shared object file 原因:TensorFlow版本 ...

  2. 运行shell脚本时报错"[[ : not found"解决方法

    问题描述 在运行shell脚本时报错,命令为: sh test.sh 报错如图: 脚本代码如下: #!/bin/bash # file:test.sh # author:13 # date:2017- ...

  3. AndroidStudio中利用git下载github或者git.oschina的代码时报错:repository test has failed解决方法

    作者:程序员小冰,CSDN博客:http://blog.csdn.net/qq_21376985 QQ986945193 微博:http://weibo.com/mcxiaobing AndroidS ...

  4. 解决ThinkPHP关闭调试模式时报错的问题汇总

    解决ThinkPHP关闭调试模式时报错的问题汇总 案例一: 最近用ThinkPHP开发一个项目,本地开发测试完成上传到服务器后,第一次打开正常,再刷新页面时就出现 "页面调试错误,无法找开页 ...

  5. 修改 docker image 安装目录 (解决加载大image时报错:"no space left on device")

    修改 docker image 安装目录 (解决加载大image时报错:"no space left on device" ) 基于Ubuntu16.04 docker版本: 17 ...

  6. 解决使用DBeaver连接MySQL时报错-The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone.

    解决使用DBeaver连接MySQL时报错,其实提示很明显. The server time zone value '�й���׼ʱ��' is unrecognized or represents ...

  7. 运行python代码报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 91: ordinal not in range(128)的解决办法

    1.通过搜集网上的资料,自己多次尝试,问题算是解决了,在代码中加上如下几句即可: import sys reload(sys) sys.setdefaultencoding('utf-8') 2.原因 ...

  8. intellij idea运行Android程序时报错;Unable to locate adb within SDK

    环境:intellij idea15 问题:运行Android时报错Throwable:Unable to locate adb within SDK   解决方法:在SDK安装目录的\platfor ...

  9. 如何解决git创建密匙时报错Too many arguments

    如题:git创建密匙时报错Too many arguments. 前几天我遇见了一个问题,git需要重新创建密匙,运行命令ssh-keygen -t rsa -b 4096 -C " you ...

随机推荐

  1. linux自建git仓库

    一 安装git,设置git用户(当前操作是root用户) 1.安装git yum install git 2.创建git用户 groupadd git useradd git -g git 3.创建证 ...

  2. 009PHP文件处理——文件处理 file_get_contents file_put_contents fgetc fgets fgetss

    <?php /** * 文件处理 file_get_contents file_put_contents fgetc fgets fgetss */ //fgetc() 传入文件操作句柄.每次获 ...

  3. hook 学习

    一.hook 是什么? Hooks Overview 二.hook 的用法 三.hook 应用

  4. qt忙等与非忙等

    非忙等: void delay(int msec) { QTime end = QTime::currentTime().addMSecs(msec); while( QTime::currentTi ...

  5. css之grid layout代码解释

    .wrapper { display: grid; grid-template-columns: repeat(3, 1fr);/*grid-template-columns CSS属性定义了网格列的 ...

  6. c++ o2 优化

    有时候,写代码的时候要卡常 这时候就要用到o2优化 #pragma GCC optimize(2) 只要把这句话加在程序开头,就可以手动开o2优化了

  7. For循环重复代码的重构

    DRY(don't repeat yourself),重复往往是代码腐烂的开始,我们一般的处理手法是将重复的代码提取成一个方法,然后用新方法替换掉原来的代码. 但是对于for循环里面的重复代码要如何处 ...

  8. JS 取出DataGrid 列

    var dt = document.all.<%= dgList.ClientID %>//找到你的grid在客户端的table for(var i = 1; i < dt.rows ...

  9. L198

    One of the most common birth defects throughout the world is a cleft lip. Babies born with a cleft l ...

  10. New Concept English Two 32 88

    $课文86  失控 940. As the man tried to swing the speedboat round, the steering wheel came away in his ha ...