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

问题描述

我正在尝试使用pictureBox-> Image(Windows窗体)显示cv :: Mat图像(openCV).我想这样做而不将图像另存为文件(因为我想每100毫秒重置一次图像).我刚刚在这里找到了该主题:如何显示简历:: Windows窗体应用程序中的垫子?

I'm trying to use pictureBox->Image (Windows Forms) to display a cv::Mat image (openCV). I want to do that without saving the Image as a file ('cause i want to reset the image every 100ms).I just found that topic here: How to display a cv::Mat in a Windows Form application?

当我使用此解决方案时,图像看起来仅是白色的.我猜我选错了PixelFormat.那么,如何确定我需要的PixelFormat?尚未在cv :: Mat中看到任何方法来获取有关此信息.还是这取决于我用来创建此cv :: Mat的图像源?到目前为止,谢谢:)

When i use this solution the image appears to be white only. I guess i took the wrong PixelFormat.So how do figure out the PixelFormat i need? Haven't seen any Method in cv::Mat to get info about that. Or does this depend on the image Source i use to create this cv::Mat?Thanks so far :)

我在这里拍了个屏幕.它不完全是白色的.所以我想这里有一些颜色信息.但是也许我错了.屏幕

Here i took a screen. Its not completely white. So i guess there is some color info. But maybe i'm wrong.Screen

推荐答案

cv :: Mat.depth()返回像素类型,例如CV_8U for 8bit unsigned etc.和 cv :: Mat.channels()返回通道数,对于彩色图像通常为3个

cv::Mat.depth() returns the pixel type, eg. CV_8U for 8bit unsigned etc.and cv::Mat.channels() returns the number of channels, typically 3 for a colour image

对于常规图像",opencv通常使用8位BGR颜色顺序,该顺序应直接映射到Windows位图或大多数Windows库中.

For 'regular images' opencv generally uses 8bit BGR colour order which should map directly onto a Windows bitmap or most Windows libs.

所以您可能想要system.drawing.imaging.pixelformat.Format24bppRgb,我不知道它使用的顺序(RGB或BGR),但是您可以将opencv cv :: cvtColor()与CV_BGR2RGB一起使用以转换为RGB

SO you probably want system.drawing.imaging.pixelformat.Format24bppRgb, I don't know what order ( RGB or BGR) it uses but you can use the opencv cv::cvtColor() with CV_BGR2RGB to convert to RGB

这篇关于cv :: Mat检测PixelFormat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-17 06:45