直接使用Mat的构造函数,把指针的位置赋给下面中的data就OK了:

Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP);

代码为matTest.cpp

 

// matTest.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <opencv2/nonfree/features2d.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/legacy/legacy.hpp"
#include<math.h>
#include <string>
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
uchar c[][];
for(int i=; i<; i++)
for(int j=; j<; j++)
c[i][j] = (i<j)?:;
imshow("x", Mat(, , CV_8UC1, (void *)c));
waitKey();
return ;
}

运行结果:

Mat(int _rows, int _cols, int _type, void* _data, size_t _step=AUTO_STEP);    

Mat(Size _size, int _type, void* _data, size_t _step=AUTO_STEP);

opencv下char数组数据显示_百度知道 https://zhidao.baidu.com/question/304116674485151964.html

char的范围是-128~127,应该用uchar类型。构造一个数据指针指向char数组的Mat。

代码测试:unsigned char*图像数据转换成OpenCV中Mat类型的更多相关文章

  1. opencv中Mat类型数据操作与遍历

    Mat作为opencv中一种数据类型常常用来存储图像,相对与以前的IplImgae类型来说,Mat类型省去了人工的对内存的分配与释放,转而自动分配释放.Mat Class主要包括两部个数据部分:一个是 ...

  2. Caffe框架,图像数据转换成LMDB数据格式

    小码农最近在研究深度学习,对所学知识做点记录,以供以后翻阅.在Caffe框架中,数据的格式都是LMDB的,如何将图像数据转换成这个格式呢? 首先,将图像数据和标签生成txt文档,执行一下代码: fin ...

  3. 将16进制unsigned char数组转换成整数

    /** * 将unsigned char数组转换成long long数值 * {0x00 0x00 0x20 0x00}转换之后得到8192 * * @param str 数组 * @param le ...

  4. 【视频开发】OpenCV中Mat,图像二维指针和CxImage类的转换

    在做图像处理中,常用的函数接口有OpenCV中的Mat图像类,有时候需要直接用二维指针开辟内存直接存储图像数据,有时候需要用到CxImage类存储图像.本文主要是总结下这三类存储方式之间的图像数据的转 ...

  5. OpenCV中Mat的列向量归一化

    OpenCV中Mat的列向量归一化 http://blog.csdn.net/shaoxiaohu1/article/details/8287528 OpenCV中Mat的列向量归一化 标签: Ope ...

  6. opencv中mat类介绍

    The class Mat represents an n-dimensional dense numerical single-channel or multi-channel array. It ...

  7. OpenCV中Mat的基本用法:创建、复制

    OpenCV中Mat的基本用法:创建.复制 一.Mat类的创建: 1.方法一: 通过读入一张图像,直接将其转换成Mat对象. Mat image = imread("test.jpg&quo ...

  8. Opencv中Mat矩阵相乘——点乘、dot、mul运算详解

    Opencv中Mat矩阵相乘——点乘.dot.mul运算详解 2016年09月02日 00:00:36 -牧野- 阅读数:59593 标签: Opencv矩阵相乘点乘dotmul 更多 个人分类: O ...

  9. OpenCV中Mat的属性

    OpenCV中Mat的属性 最近在做一OpenCV的图像轮廓检验,但当用到霍夫变换时才发现对Mat的属性了解不足.Mat在OpenCV中的地位是及其重要的,因此有必要做一个总结. 大体上来说,Mat是 ...

随机推荐

  1. 剑指offer-5:十进制转二进制

    一.二进制中‘1’的个数 输入一个整数,输出该数二进制表示中1的个数.其中负数用补码表示. public class Solution { public int NumberOf1(int n) { ...

  2. vue项目报错1 Vue is a constructor and should be called with the `new` keyword && jquery.js?eedf:3850 Uncaught TypeError: this._init is not a function...

    Vue is a constructor and should be called with the `new` keyword Uncaught TypeError: this._init is n ...

  3. 一、doT.js使用笔记

    一.赋值https://www.jianshu.com/p/19156f9fac1e <!DOCTYPE html> <html> <head> <meta ...

  4. lnmp 环境搭建后,pathinfo 模式支持的配制。

    ThinkPHP的四种URL模式:0(普通模式);1(PATHINFO模式);2(REWRITE模式);3(兼容模式) nginx需要PATHINFO模式,但需要更改nginx配置文件让其支持PATH ...

  5. 解决CRMEasy新建咨询不能保存问题

    系统时间必须为24H制 将12H制修改为24H制的方法:(XP系统) 控制面板---区域和语言选项----区域选项-----自定义---时间----时间格式为:HH:mm:ss-----确定

  6. php中禁止单个ip与ip段访问的代码小结

    1.禁止单个IP <?php //IP访问限制 if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP' ...

  7. JSTL标签(转载)

    JSTL标签是一个实现web功能的定制标签库,包括输出功能,条件判断,循环等,使用JSTL标签,为动态编写WEB应用程序提供了很大的方便性,能很好的和Java语言和HTML进行结合.下面我们看看jst ...

  8. js常用操作

    map操作:var map = {};map["a"] = 1;map["b"] = 2; console.log(Object.keys(map)); //[ ...

  9. 多线程使用@Async注解创建多线程,自定义线程池

    转载自博客https://www.jianshu.com/p/7ac04a501eba

  10. HDU-4810-wall Painting(二进制, 组合数)

    链接: https://vjudge.net/problem/HDU-4810 题意: Ms.Fang loves painting very much. She paints GFW(Great F ...