简体   繁体   English

使用渲染脚本进行图像处理

[英]image processing using Renderscripts

I am trying to have a renderscript calculate the min and max of a photos pixels rgb. 我试图让一个renderscript计算照片像素rgb的最小值和最大值。 I don't need the min and max in my java if I can keep the memory in the RS. 如果可以将内存保留在RS中,则不需要Java中的min和max。 How will i know if i have the memory to keep the min and max on the gpu? 我怎么知道我是否有保留最小和最大的内存的内存? I am snapping photos every 3 seconds and i want to know if some thing is moving in the cameras field of view. 我每3秒拍摄一次照片,我想知道照相机视场中是否有东西在移动。 I like the idea of learning the scene with the min and max values of the color and comparing the next snapshot with the min and max. 我喜欢用颜色的最小值和最大值来学习场景并将下一个快照与最小值和最大值进行比较的想法。 I am familiar with most examples on the web relating to renderscripts but I don't know the best way to handle this. 我熟悉网络上与渲染脚本有关的大多数示例,但我不知道处理此问题的最佳方法。 A code snippet would be awesome. 一个代码片段会很棒。

Thanks 谢谢

Renderscript for gpu is supported only on a handful devices right now. 目前只有少数设备支持gpu的Renderscript。 So depending on the gpu might not be what you're looking for. 因此,取决于gpu可能不是您要查找的内容。 Also, renderscript is only useful to speed up the tight loops in your code (like looping over an entire image). 另外,renderscript仅用于加快代码中的紧密循环(例如遍历整个图像)。

From what I can think, you need to move your renderscript data into your program to do any kind of decision making. 从我的想法来看,您需要将renderscript数据移至程序中以进行任何决策。

You can make an allocation with just two numbers (bytes, floats, etc). 您可以只用两个数字(字节,浮点数等)进行分配。 Pass it to the renderscript and let it iterate over the image. 将其传递给渲染脚本,并使其遍历图像。 Then the renderscript populates allocation and you can access it inside Java. 然后,渲染脚本填充分配,您可以在Java内部访问它。 You can maintain an array in your Java code 您可以在Java代码中维护数组

PS: Using an allocation is important because you can't access individual variables from a renderscript in your Java code (apparently this was a design choice). PS:使用分配很重要,因为您无法从Java代码中的渲染脚本访问各个变量(显然,这是一种设计选择)。 So something like this would be inaccessible to your Java code: 因此,您的Java代码将无法访问以下内容:

int max, min     // in renderscript

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM