获取AVCaptureSession samplebuffer 一像素的 rgb值
获取AVCaptureSession samplebuffer 一像素的 rgb值
typedef unsigned char byte;
typedef struct RGBPixel{
byte red, green, blue;
} RGBPixel; - (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{ CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer,); size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t height = CVPixelBufferGetHeight(imageBuffer);
uint8_t *src_buff = (uint8_t*)CVPixelBufferGetBaseAddress(imageBuffer); CVPixelBufferUnlockBaseAddress(imageBuffer, );
RGBPixel *pixelData = (RGBPixel *)src_buff; int len = bytesPerRow * height;
for(int i=; i<len; i+=){ RGBPixel pixel = pixelData[i/]; int a = ;
int r = pixel.red;
int g = pixel.green;
int b = pixel.blue; NSLog(@"first values = r:%d g:%d b:%d", r, g, b); a = src_buff[i+];
r = src_buff[i+];
g = src_buff[i+];
b = src_buff[i]; NSLog(@"second values = r:%d g:%d b:%d", r, g, b); } }
如果是BGRA
typedef struct RGBPixel{
byte blue, green, red;
} RGBPixel;
参考:http://iphonedevsdk.com/forum/iphone-sdk-development/
获取AVCaptureSession samplebuffer 一像素的 rgb值的更多相关文章
- 获取屏幕中某个点的RGB值与CAD屏幕像素值
'获取CAD屏幕像素的比值 Function ViewScreen() As Double Dim ScreenSize As Variant ScreenSize = ThisDrawing.Get ...
- opencv 中对一个像素的rgb值或像素值进行操作的几个常用小办法【转】
You can access the Image pixels in many ways:1. One using the Inbuilt macro2. One using the pointer ...
- 获取UIColor中的RGB值(本人亲测多个获取RGB值的方法,这个最有效)
在自己研发的项目个人项目中,碰到一个从颜色中获取RGB值的需求. 在网上找了许久,也有一些方法可以获取RGB值,但不能获取黑白以及灰色的值(他们是非RGB颜色空间,不清楚什么意思,反正亲测确实获取不了 ...
- [OpenCVsharp]利用指针实现高速访问像素RGB值
先简单介绍下什么是OpenCVsharp,内容取自百度百科 OpenCvSharp是一个OpenCV的.Net wrapper,应用最新的OpenCV库开发,使用习惯比EmguCV更接近原始的Open ...
- Qt ------ 截图、获取鼠标指定的RGB值
获取RGB值思路:截图,获取图片的(0,0)的RGB值 int x = QCursor::pos().x(); int y = QCursor::pos().y(); // QPixmap pixma ...
- 用Delphi直接获取bmp图片的像素
用Delphi直接获取bmp图片的像素,并存储显示出.(此像素主要用在LED上显示).希望高手能给出代码啊!! function getImagePixels(f: string): Integer; ...
- rgb值转换成16进制
由于jQuery获取css中的background有时候是rgb值,所以往往需要一个转换函数. 以前觉得难,还写个博客记录,现在觉得好容易. let testColor = "rgb(20, ...
- 获取URL的code的参数的值
1.获取URL的code的参数的值 需求说明:现在有URL为http://www.bdqn.cn/index.php?code=sdR4,请使用字符串对象的属性和方法来获取code的值,并把其指都转化 ...
- 如何获取Iframe的页面控件的值
有时候我们在页面需要使用iframe的方法来引用另一个页面,虽然个人建议不要使用iframe哈,但是有些时候是没得法了才使用的咯,那么在使用的过程中也会遇到某一些问题,我将自己遇到的问题记录下来方便以 ...
随机推荐
- hdu 2258 优先队列
Continuous Same Game (1) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- require.js的简单使用
<script src="js/require.js"></script> <script src="js/require.js" ...
- sass的安装与基础
安装教程:http://www.haorooms.com/post/sass_css 手册:http://sass.bootcss.com/docs/guide/ http://www.w3c ...
- 如何把drawing图像转换成wpf控件的source
此例以canvas为例 <Canvas> <Image Stretch="Fill" Width="100" Height="10 ...
- 2016年11月13日 星期日 --出埃及记 Exodus 20:4
2016年11月13日 星期日 --出埃及记 Exodus 20:4 "You shall not make for yourself an idol in the form of anyt ...
- WebForm分页浏览
1.封装类 //封装类 using System; using System.Collections.Generic; using System.Web; /// <summary> // ...
- MVC 中DropDownList 用法
MVC 中DropDownList 用法 后台 Dictionary<string, int> dc = new Dictionary<string, int>(); dc. ...
- MVC 中使用EF
EF 1)简单查询 后台代码 using MvcApplication18.Models; using System; using System.Collections.Generic; using ...
- GCD之dispatch queue深入浅出
GCD之dispatch queue深入浅出 http://blog.csdn.net/samuelltk/article/details/9452203
- JSON 数据解析
json解析的几种方法(将字符串解析为object对象和objectArray对象数组) 1 Android自带api 包名 org.json // json = {"school&quo ...