在iPhone屏幕上检测亮点/暗点 [英] Detecting bright/dark points on iPhone screen

查看:260
本文介绍了在iPhone屏幕上检测亮点/暗点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测并标记图像上最亮和最暗的点.

I would like to detect and mark the brightest and the darkest spot on an image.

例如,我正在创建一个AVCaptureSession并使用AVCaptureVideoPreviewLayer在屏幕上显示视频帧.现在,在此摄像机输出视图上,我希望能够标记当前最暗和最亮的点.

For example I am creating an AVCaptureSession and showing the video frames on screen using AVCaptureVideoPreviewLayer. Now on this camera output view I would like to be able to mark the current darkest and lightest points.

我必须读取图像像素数据吗?如果是这样,我该怎么办?

Would i have to read Image pixel data? If so, how can i do that?

推荐答案

在任何情况下,您都必须读取像素才能检测到这一点.但是,如果您想使其速度更快,请不要读取每个像素:只能读取100个像素中的1个:

In any case, you must to read pixels to detect this. But if you whant to make it fast, dont read EVERY pixel: read only 1 of 100:

for (int x = 0; x < widgh-10; x+=10) {
   for (int y = 0; y < height-10; y+=10) {
      //Detect bright/dark points here
   }
} 

然后,您可以读取找到的像素周围的像素,以使结果更正确

Then, you may read pixels around the ones you find, to make results more correct

这是获取像素数据的方法:stackoverflow.com/questions/448125/…...在最亮的地方,红色+绿色+蓝色必须最大(225 + 225 + 225 = 675 = 100%白色).在最暗的位置,红色+绿色+蓝色必须最小(0 = 100%黑色).

here is the way to get pixel data: stackoverflow.com/questions/448125/… ... at the most bright point, red+green+blue must be maximum (225+225+225 = 675 = 100% white). At the most dark point red+green+blue must bo minimum (0 = 100% black).

这篇关于在iPhone屏幕上检测亮点/暗点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆