前言

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. c++ 二分法查找(binary_search)

    #include <iostream> // cout #include <algorithm> // binary_search, sort #include <vec ...

  2. ubuntu 14.04 安装 glog

    1.下载 git clone https://github.com/google/glog 2.配置 sudo apt-get install autoconf automake libtool 3. ...

  3. Spring Boot中注解事务

  4. 二分检索函数lower_bound()和upper_bound()

    二分检索函数lower_bound()和upper_bound() 一.说明 头文件:<algorithm> 二分检索函数lower_bound()和upper_bound() lower ...

  5. Eclipse 设置代码风格

    自动调整代码风格 快捷键Ctrl + Shift + F 或者 右键 source -> format 设置代码风格 window -> preference -> java -&g ...

  6. 20170528xlVBA凑数一例

    Public Sub MakeUp() Dim Sht As Worksheet Set Sht = ThisWorkbook.Worksheets("设置") Dim Total ...

  7. Many Easy Problem

    转自hwk0518,不胜感谢,侵删.

  8. FastDFS install - 2

    storage install nginx 1. update dependency package yum -y install pcre-devel openssl openssl-devel g ...

  9. service几种访问类型(集群外负载均衡访问LoadBalancer , 集群内访问ClusterIP,VPC内网负载均衡LoadBalancer ,集群外访问NodePort)

    一.集群外访问(负载均衡) kind: ServiceapiVersion: v1spec: ports: - protocol: TCP port: 4341 targetPort: 8080 no ...

  10. 字符串 dfs

    1222: FJ的字符串 [水题] 时间限制: 1 Sec 内存限制: 128 MB 提交: 52 解决: 9 状态 题目描述 FJ在沙盘上写了这样一些字符串: A1  =  “A” A2  =  “ ...