极快的getpixel [英] extreme fast getpixel

查看:60
本文介绍了极快的getpixel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种非常快的方法来获取getpixel.

我尝试了一些方法,但是结合120 fps的实时摄像头还不够快吗?

..,我开始怀疑,如果我进入汇编器,也许只能实时"完成(我宁可不要,几年前我做了那样,需要再次学习).但是速度

I''m looking for an extremely fast method to do getpixel.

I tried some methods but they where just not fast enough in combination with a live cam 120fps any suggestions ?

.., i''m beginning to wonder maybe it can only be done "live" if I go into assembler (which i rather do not, its been years ago that i did that, need to learn it again).. but speed is to slow even with lockbit images.

推荐答案

你好,

要以高速率处理视频,您应该使用GPU.
您可以使用Direct3D和HLSL或OpenGL和GLSL来生成效果或进行一些图像处理. CUDA和OpenCL提供了更复杂的功能.
仅通过CPU数据传输数据将是DirectDraw或Direct3D.
为了更好地使用DXVA2或CUDA或OpenMP进行编码,加上有用的将是Intel的并行工作室及其与之相关的东西,以进行高性能的并行数据处理.阅读abt SIMD也会很有帮助.

问候,
Maxim.
Hello,

For processing video on high rate you should use GPU.
You can use Direct3D and HLSL or OpenGL and GLSL for building effects or made some image processing. More complex things are available with CUDA and OpenCL.
For just blitting the data over CPU enougth will be DirectDraw or Direct3D.
For encoding better to use DXVA2 or CUDA or OpenMP plus usefull will be Intel''s parallel studio and it related stuff for parallel data processing with high performance. Also helpful will be reading abt SIMD.

Regards,
Maxim.


如果您真的想要GetPixel/SetPixel,则只能在只需要几个像素的情况下进行,而速度无关紧要.如果您需要复制或修改许多像素,则整个想法毫无意义.无论如何努力,您都将无法快速完成此任务.方法是不同的:您需要一次固定整个数据数组的内存,然后通过指针(不安全代码)或数组索引将其用于大量操作.在这种情况下,每个像素的平均访问时间可能会很小,这就是您所需要的.

现在,您没有解释要使用什么成像库.通常,您可以使用与System.Windows.Forms一起使用的System.Drawing或仅使用位图,或者使用WPF.在所有或某些平台上都可能有其他产品(不是来自Microsoft的产品).问问题时,应始终标记此类内容.

对于Forms,您需要使用BitmapLockBits:
http://msdn.microsoft.com/en-us/library/system. drawing.bitmap.lockbits.aspx [ ^ ].

对于WPF,可以使用System.Windows.Media.Imaging.BitmapImage.如果需要编写位图,则需要使用
请参阅:
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource.aspx#inheritanceContinued [ http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx [ ^ ].

您最好不要将System.DrawingWPF混合使用,但是,如果绝对必要,则可以使用一个互操作库:
http://msdn.microsoft.com/en-us/library/ms608869.aspx [ ^ ].

我不建议参加互操作.最好选择其中一种.

—SA
If you really want GetPixel/SetPixel, it can only be in the cases where you need only few pixels, and then speed does not matter. If you need to copy or modify many pixels, the whole idea makes no sense. And you won''t be able to do it fast anyway, no matter how hard you try. The approach is different: you need to pin a memory for a whole array of data at once and use it through pointers (unsafe code) or array indexing for massive operations. In this case, average access time per pixel can be quite small, which is all you need.

Now, you did not explain what imaging library do you want to use. Usually, you use either System.Drawing, which is used with System.Windows.Forms or just bitmaps, or, alternatively, you use WPF. It could be something else, not from Microsoft, available on all or some platforms. You should always tag such things when asking questions.

For Forms, you would need to use, BitmapLockBits:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx[^].

For WPF, you can use System.Windows.Media.Imaging.BitmapImage. If you need to write bitmap, you would need to use
Please see:
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource.aspx#inheritanceContinued[^],
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx[^].

You should better not mix System.Drawing with WPF, but, if it''s absolutely necessary, there is an interop library:
http://msdn.microsoft.com/en-us/library/ms608869.aspx[^].

I would not recommend to go into interop; it''s much better to choose one of the alternatives.

—SA


这篇关于极快的getpixel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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