0

When I stream with the picturebox, there is a decrease in performance. I'm looking for a library that supports 4k 30fps. I think Opengl will support it. I shared my code below. I need a higher performance viewer instead of Picturebox. Are examples of this available for Opengl?

I have a c ++ dll. I convert the 4k 30fps data from gstreamer to bitmap and print it to the screen.

pt = DLLWrapper.WrapperSingleCameras (0) is returning the 4k30fps frame from the stream as a pointer.

pt = DLLWrapper.WrapperSingleCameras(0);
BitmapSingleImage = new Bitmap(rsSplitWidth, rsSplitHeight, rsSplitWidth, System.Drawing.Imaging.PixelFormat.Format8bppIndexed, (IntPtr)pt);
                         
ColorPalette _palette = BitmapSingleImage.Palette;
System.Drawing.Color[] _entries = _palette.Entries;

for (int m = 0; m < 256; m++)
{
    System.Drawing.Color b = new System.Drawing.Color();
    b = System.Drawing.Color.FromArgb((byte)m, (byte)m, (byte)m);
    _entries[m] = b;
}

BitmapSingleImage.Palette = _palette;

videosGUI.videoPictureBox.Image = BitmapSingleImage;
videosGUI.videoPictureBox.Refresh();
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • It looks like you're maybe reading stuff from a webcam? Can you please explain your use case better in your question? – AKX Aug 07 '20 at 13:30
  • (Also, it looks like you're recomputing a greyscale ramp palette over and over again for each frame, even if it doesn't change?) – AKX Aug 07 '20 at 13:31
  • yes, I turn the color palette to black and white. I edited the subject, I'm sorry, it was not fully explanatory. The example above works fine. but I can't get 30 fps at 4k. It runs at 30fps in the background when I don't print the image on the screen. I need a more performing object to support the picturebox instead. – Muratakaydin Aug 07 '20 at 13:35
  • Well, you can paint your image directly on a Form's `Graphics`, for one, to avoid having a PictureBox in there. Are you actually drawing onto a 4K picturebox? Could you resize the image somewhere inbetween? – AKX Aug 07 '20 at 13:38
  • (But either way, you can compute that `ColorPalette` only once, and assign it to each frame. That'll optimize things to begin with.) – AKX Aug 07 '20 at 13:40
  • You cannot go with GDI. First you are CPU bound. I just ran a test of generating an empty bitmap of 4k without setting the pixels yet and that's 12 ms. So displaying a black image just that i can reach a maximum of 83 fps if you start filling the image from a stream you will cut your FPS drastically. Also i doubt your control will be 4K full screen winforms. You likely gonna be lower resolution than that so you will be downscaling anyway. Why not just putting the stream into a window media player control or VLC stream ? – Franck Aug 07 '20 at 13:50
  • Thank you AKX for your comment. I will consider. Franck, I don't know what else I can use. Can I show the instant bitmap data on the screen with VLC or media player controller? – Muratakaydin Aug 07 '20 at 14:04
  • and I don't reduce my resolution. the final version has to be 4k30fps. – Muratakaydin Aug 07 '20 at 14:06
  • 4K30fps 4 streams are coming from 4 different sources. I decode these streams in GPU with gstreamer. I down scale the incoming broadcasts, combine 4 frames on the coordinate plane and send them as a single frame. The last frame that comes is 3840x2160. I have a 4k monitor. I am trying to instantly show the broadcast in 4k30fps on this monitor. But the picturebox prevents me. – Muratakaydin Aug 07 '20 at 14:12
  • @Muratakaydin gstreamer back in the days could stream directly into video player control in winforms directly. – Franck Aug 07 '20 at 14:48
  • @Franck I'm doing a lot of operations in the background. (combining frames, filters, etc.). So I need an object that instantly stream the bitmap I mentioned in the script. – Muratakaydin Aug 07 '20 at 14:49
  • So you want to apply a live filter to 4 x 4K stream ? Your stream reader should read, modify (apply filter) and send along the resulting stream and you hook the video player to that. – Franck Aug 07 '20 at 15:04
  • @Franck no i just want an object like picturebox that can show 4k30fps stream without breaking it – Muratakaydin Aug 07 '20 at 15:10
  • @Muratakaydin As i will repeat again, use a video player to read the video stream. it is meant to do that. – Franck Aug 07 '20 at 15:29
  • @Franck Can I send the bitmap object to the video player? In all the examples I have seen, the video players only play a recorded video source (such as. mp4). – Muratakaydin Aug 10 '20 at 05:52
  • @Muratakaydin No, windows media player and VLC can read video streams – Franck Aug 10 '20 at 12:46
  • @Franck so I need a library like picturebox where I can stream bitmap object. – Muratakaydin Aug 10 '20 at 12:49
  • @Muratakaydin Technically there is no need for special library. you can create a video stream yourself with the codex you have already installed. Although it's probably easier with third party libraries. With ffmpeg for example it's possible to generate video from list of images so it might be possible to stream that output instead of saving to disk. – Franck Aug 10 '20 at 12:55
  • @Franck Can I do this in real time? I want to write the following code, which I read 30 times a second, to another object instead of the picture box. pt = DLLWrapper.WrapperSingleCameras (0); BitmapSingleImage = new Bitmap (rsSplitWidth, rsSplitHeight, rsSplitWidth, System.Drawing.Imaging.PixelFormat.Format8bppIndexed, (IntPtr) pt); videosGUI.videoPictureBox.Image = BitmapSingleImage; videosguı.videopicturebox.refresh (); – Muratakaydin Aug 11 '20 at 05:09

0 Answers0