简体   繁体   中英

Display raw image as video on winform (over 30fps)

I receive 30 raw images per second via USB. (real time camera iamge / but not webcam)

// raw image is Format32bppPArgb Bitmap

while ( true ) // Recevie Image loop Using Task
{
    ...
    picturebox1.Image = raw_image;
    // panel1.BackgroundImage = raw_image; // or using panel to display
    ...
}

I updated the image to make it look like an Video. When the image is 15fps, it's the program working properly. But 30fps, GUI is broken. The image area is refreshed smoothly and well. However, other components will not be updated if there is a change, causing problems. (such as radiobutton, panel, title bar, etc..) This seems to occur noticeably when the area of drawing the image is widened.

As a result of referring to other articles in stackoverflow, I was able to check some related information, but I couldn't solve it clearly using Winform. it seems that fast redrawing in this way is difficult through winform. (I don't know if I got it right.)

Are there any good ways or keywords to solve this problem? Thank you for reading it.

I had a similar problem. It helped me when I called the Refresh() and Update() functions at any change on the surrounding controls.

// Label is only example, you can user any control you like
private void ChangeLabel()
{
    label1.text = "new text";
    label1.Refresh();
    label1.Update();
}

Maybe it would be enough to add only one of the functions.

The default bitmap resizing was thought to be heavy. 'zoom mode' has been changed to 'none'. The image was resized to fit the panel size before making it into a bitmap. (this case, i use opencvsharp resize / image.ToBitmap() )

The image was created and call invalidate(). Displayed through "Graphics.DrawImage" in the panel's "onpaint event". Now everything is working normally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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