前言

Opencv中可以调用函数提取某些连续的行或者列,Mat的rowRange和colRange可以获取某些范围内行或列的指针;

这两个函数返回的是指向原矩阵内部位置的指针,类似于浅拷贝;

example

cv::Mat align_mean(cv::Mat mean, cv::Rect facebox, float scaling_x=1.0f, float scaling_y=1.0f, float translation_x=0.0f, float translation_y=0.0f)
{
using cv::Mat;
// Initial estimate x_0: Center the mean face at the [-0.5, 0.5] x [-0.5, 0.5] square (assuming the face-box is that square)
// More precise: Take the mean as it is (assume it is in a space [-0.5, 0.5] x [-0.5, 0.5]), and just place it in the face-box as
// if the box is [-0.5, 0.5] x [-0.5, 0.5]. (i.e. the mean coordinates get upscaled)
Mat aligned_mean = mean.clone();
Mat aligned_mean_x = aligned_mean.colRange(, aligned_mean.cols / );
Mat aligned_mean_y = aligned_mean.colRange(aligned_mean.cols / , aligned_mean.cols);
aligned_mean_x = (aligned_mean_x*scaling_x + 0.5f + translation_x) * facebox.width + facebox.x;
aligned_mean_y = (aligned_mean_y*scaling_y + 0.3f + translation_y) * facebox.height + facebox.y;
return aligned_mean;
}

 引申

如果要提取Mat数据某些间隔的行、列呢??比如只提取奇数行或者偶数行,或者每隔3行提取数据。。。

分析:之前博主是由vector得到的Mat,所以可以在最开始得到Mat的过程中就间隔提取数据。

参考

1. OpenCV从Mat中提取某些行或列

【opencv基础】OpenCV从Mat中提取某些行或列的更多相关文章

  1. 调用opencv相关函数,从视频流中提取出图片序列&&&&jpg图片序列,转化成avi格式视频

    /************************ @HJ 2017/3/30 参考http://blog.sina.com.cn/s/blog_4b0020f301010qcz.html修改的代码 ...

  2. 【转】MySQL存储过程中使用动态行转列

    MySQL存储过程中使用动态行转列 最近做项目关于数据报表处理,然而数据库存储格式和报表展现形式不同,需要进行一下行转列的操作,在做上一个项目的时候也看了一下,但是后来换了读取方式,也就没深入研究这个 ...

  3. WPF 在画布中布局N行N列的实现方法

    最近写一个WPF项目,中间有一个实现在画布中排列的问题(整齐摆列几行几列的算法).本人逻辑有点差啊,废了老大功夫才实现,也没啥就牛逼的,就是拿出来分享一下,给需要的同学节省点时间,如果有用的话别忘赞一 ...

  4. 用JavaScript,获取Table中指定的行、列

    前言: 先要谢谢George Wing的慷慨赠书<悟透JavaScript>,让我更加感受到了技术交流的重要性,呵呵~ 进入正题,面试题中有一题:如何通过JavaScript获取Table ...

  5. Bootstrap3基础 栅格系统 列中有行,行中有列

      内容 参数   OS   Windows 10 x64   browser   Firefox 65.0.2   framework     Bootstrap 3.3.7   editor    ...

  6. 转Delphi中Memo显示行号列号

    http://www.alonely.com.cn/Delphi/20160814/8912.html 实例说明本例是个光标应用的简单技巧,希望通过这个例子的学习后能举一反三.Delphi中像这样简单 ...

  7. 在GridView的RowDataBound事件中获取某行某列的值!

    protected void gdvOrders_RowDataBound(object sender, GridViewRowEventArgs e)   {               if (e ...

  8. SQL Server中使用PIVOT行转列

    使用PIVOT行转列 1.建表及插入数据 USE [AdventureDB] GO /****** Object: Table [dbo].[Score] Script Date: 11/25/201 ...

  9. Hive基础之Hive开启查询列名及行转列显示

    Hive默认情况下查询结果里面是只显示值: hive> select * from click_log; OK ad_101 :: ad_102 :: ad_103 :: ad_104 :: a ...

随机推荐

  1. shell 杀掉指定进程的服务

    check_results=`ps -ef|grep bp_driver.launch|awk '{print $2}'|sed -n 1p` echo `kill - $check_results` ...

  2. Seafile 文件访问日志时间不一致问题

    修改/seafile-server-latest/seahub/seahub/setting.py # Local time zone for this installation. Choices c ...

  3. Android蓝牙通信功能开发

    1. 概述 Bluetooth 是几乎现在每部手机标准配备的功能,多用于耳机 mic 等设备与手机的连接,除此之外,还可以多部手机之间建立 bluetooth 通信,本文就通过 SDK 中带的一个聊天 ...

  4. 使用SFTP工具相关问题

    1.使用SFTP工具,填写ip,端口都正确但是连接不上?         答:请统一使用 filezilla工具进行连接,环境搭建使用该工具进行测试和使用.           2.使用SFTP工具访 ...

  5. 总是有个yumBackend.py阻止我用yum进行更新

    [Another app is currently holding the yum lock; waiting for it to exit...] 上网查了,好像是说帮我安个桌面图标的进程. 估计是 ...

  6. 雷林鹏分享:Ruby 数据类型

    Ruby 数据类型 本章节我们将为大家介绍 Ruby 的基本数据类型. Ruby支持的数据类型包括基本的Number.String.Ranges.Symbols,以及true.false和nil这几个 ...

  7. XAML中格式化日期

    要求被格式化数据的类型是DateTime StringFormat='yyyy-MM-dd' StringFormat={}{0:yyyy-MM-dd}

  8. 013 - 关于GC root: Native Stack | MAT分析

      Question:   I have some third library code that I run and after some time I run into OutOfMemoryEr ...

  9. LeetCode--083--删除排序链表中的重复元素

    问题描述: 给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次. 示例 1: 输入: 1->1->2 输出: 1->2 示例 2: 输入: 1->1->2-&g ...

  10. 12月12日 has_many through:的interference, option

    has_many :products, through: :cart_items, source: :product build定义:collection.build(attributes = {}, ...