当前位置: 首页 > news >正文

opencv-rust 系列: 1, 安装及运行自带示例和测试程序

opencv-rust 系列: 1, 安装及运行自带示例和测试程序

    • 运行环境: ubuntu ; rust 已安装; 对rust的掌握为三脚猫程度
    • 一. opencv-rust安装:
    • 二. 运行自带examples和tests

运行环境: ubuntu ; rust 已安装; 对rust的掌握为三脚猫程度

一. opencv-rust安装:

  1. 安装软件: sudo apt install libopencv-dev clang libclang-dev llvm (clang就是llvm部分)
  2. 查看版本: sudo apt show libopencv-dev ( 目前20241006支持OPENCV 4.6.0)

二. 运行自带examples和tests

  1. 安装最新的opencv库,命令: cargo add opencv ( 此时20241006, 库版本为 0.93.1 )
  2. 使用命令: locate opencv-0.93 找到库所在目录
  3. 复制一份到本地, 例如: cp -av /home/wzw/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.93.1 ./
  4. 运行自带示例(示例在examples目录中)
    1. 命令如: cargo run --example video_capture ( 摄像并显示 )
    2. 命令如: cargo run --example video_facedetect ( 人脸测试 )
    3. 备注: examples/ 目录中的程序都可以试试, 有些程序运行需要参数
  5. 运行自带的测试程序
    1. 命令: cargo test
      1. 报错: error[E0599]: no method named points_vec found for struct RotatedRect in the current scope --> tests/core_only_latest_opencv.rs:11:7
      2. 修改程序: tests/core_only_latest_opencv.rs
        1. 被替换内容:
          let mut vec_pts = Vector::new();
          rect.points_vec(&mut vec_pts)?;
          assert_eq!(Point2f::new(50., 50.), vec_pts.get(0)?);
          assert_eq!(Point2f::new(150., 50.), vec_pts.get(1)?);
          assert_eq!(Point2f::new(150., 150.), vec_pts.get(2)?);
          assert_eq!(Point2f::new(50., 150.), vec_pts.get(3)?);
        2. 替换成:
          let mut vec_pts = [Point2f::new(0.0, 0.0); 4];
          rect.points(&mut vec_pts)?;
          assert_eq!(Point2f::new(50., 50.), *vec_pts.get(0).unwrap());
          assert_eq!(Point2f::new(150., 50.), *vec_pts.get(1).unwrap());
          assert_eq!(Point2f::new(150., 150.), *vec_pts.get(2).unwrap());
          assert_eq!(Point2f::new(50., 150.), *vec_pts.get(3).unwrap());
      3. 现在再 cargo test 就可以运行通过了. ( 有两个 warning 可以忽略 )
http://www.lryc.cn/news/454306.html

相关文章:

  • Linux系统编程(一):Linux平台上静态库和动态库的制作与使用
  • Nginx的基础讲解之重写conf文件
  • RIFE: Real-Time Intermediate Flow Estimation for Video Frame Interpolation
  • rabbitMq-----broker服务器
  • MAC备忘录空白解决方案
  • cnn突破七(四层bpnet网络公式与卷积核bpnet公式相关)
  • PHP中的PEAR是什么
  • (C语言贪吃蛇)4.贪吃蛇地图优化及算法说明
  • 国外电商系统开发-运维系统拓扑布局
  • 使用winsock和ip相关指令重置Window网络配置
  • 用AI做电子萌宠,快速涨粉变现
  • 如何在 Axios 中封装事件中心EventEmitter
  • 计算机网络——ftp
  • Redis:set类型
  • 九大排序之插入排序
  • DNABERT: 一个基于 Transformer 双向编码器表征的预训练 DNA 语言模型
  • 基于Hive和Hadoop的电商消费分析系统
  • 记一次炉石传说记牌器 Crash 排查经历
  • 精益驱动的敏捷开发
  • SolidWorks机器转ROS2 URDF
  • (Linux驱动学习 - 6).Linux中断
  • SpringBoot驱动的明星周边产品电商解决方案
  • C++、Ruby和JavaScript
  • 32单片机 低功耗模式
  • 501、二叉搜索树中的众数
  • 【洛谷】P2330 [SCOI2005] 繁忙的都市 的题解
  • 第18场小白入门赛(蓝桥杯)
  • Redission · 可重入锁(Reentrant Lock)
  • 初阶C语言-指针
  • 论文笔记:微表情欺骗检测