微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

性能更新-WPF中更好的图像帧率

如何解决性能更新-WPF中更好的图像帧率

| 我正在.Net 4.0中的WPF中工作。我有一些来自相机1392x1040像素的巨大图像。每帧为
System.Drawing.Bitmap
,并将通过使用转换为BitmapImage
Public Function BitmapToWpfBitmapSource(ByVal bmSrc As System.Drawing.Bitmap) As BitmapSource
                    If bmSrc Is nothing Then Return nothing
                    Dim res As BitmapSource
                    Dim Ptr As IntPtr
                    Ptr = bmSrc.GetHbitmap(System.Drawing.Color.Black) \'Create GDI bitmap object
                    res = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Ptr,IntPtr.Zero,System.Windows.Int32Rect.Empty,BitmapSizeOptions.FromWidthAndHeight(bmSrc.Width,bmSrc.Height))
                    Dim ret As Integer = DeleteObject(Ptr) \'Delete GDI bitmap object
                    GC.Collect() \'Because the code is not managed,we need to call the collector manually to avoid memory spikes
                    Return res
End Function
如果我在GUI中更新图像,我可以得到大约7帧/秒。   通过降低质量,可以提高速度: 与最近的邻居渲染
RenderOptions.SetBitmapScalingMode(Me.ucWindow1.VideoPresenter1.img1,BitmapScalingMode.NearestNeighbor)
使用线程来更新每一帧 昏暗的dl作为新的SetimageDelegate(AddressOf UpdateImageInGuiGuiThread) Me.dispatcher.Invoke(dl,imgSrc) 经过32位和24位图像测试- 比较Imageformat 使用性能分析套件进行帧率计数 但是cpu仍然大约是10%,而不是100%,帧速率最大约为12FPS,而不是39(Winforms)。 如何提高相机的帧率?     

解决方法

        如果CPU为10%,则除了处理图像外,还会发生其他情况。我怀疑您的问题的答案是您在这里没有提到的。例如从磁盘读取或从相机读取。     ,        我怀疑您的GPU负载过高。完成类似程序后,WPF渲染将使用大量GPU资源,这很容易成为瓶颈。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。