Resize make wx python interface slower

I am opening multiple IP cameras live stream when I am resizing the interface multiple times the interface, the stream is becoming slower.
can you please advise


You haven’t provided any information about how your application works, how it captures the live streams and in what format, how the wxPython interface is implemented, how the frames from the captured stream are converted for display in the wxPython controls, or what is done to the data when the interface is resized.

If the images generated from the frames are being resized from the native size provided by the camera to a size that fits the available space in the interface, then that will obviously add additional time and reduce performance. If the performance keeps deteriorating each time the interface is resized, it suggests there is something else happening. Without seeing any code, I don’t know what could be the cause.

The only experience I have in this area is from a simple demo app I adapted that runs a timer to capture frames from a webcam using the opencv-python package. The captured frames consist of numpy.ndarray objects which are convert wx.Bitmaps, which are then applied to a wx.StaticBitmap. It does work, but the performance on my linux PC is not too impressive, even though it doesn’t do any resizing. And that’s with just one webcam, whereas you are talking about multiple cameras.

One way to resize the images would be to call the wx.Bitmap’s Rescale method. I don’t know if the numpy.ndarray objects could be resized directly, or whether that would be more efficient than the wxPython method. Of course, you may be using totally different libraries and formats anyway…

I’ve done some more experiments with my simple webcam viewer application.

The EVT_TIMER event handler that gets a video frame from the webcam, converts its colour-space, converts it to wx.Bitmap and applies it to the wx.StaticBitmap takes on average 0.001 to 0.003 seconds without doing any resizing.

When I added some simple code to resize the bitmap to fit the interface, the timing for the event handler increased slightly to 0.003 to 0.009 seconds. That was using the default wx.IMAGE_QUALITY_NORMAL, which sacrifices quality for speed. When I used wx.IMAGE_QUALITY_BILINEAR it increased to 0.01 to 0.03 seconds, but the image quality was better.

I found that with the timer interval set to about 55 milliseconds, there wasn’t really any need to use an EVT_SIZE event handler, as the refreshing due to the timer was able to keep up with the resizing.

One thing to bear in mind is that if you do have an EVT_SIZE handler, a simple operation like increasing the size of the window by a few centimetres can sometimes generate 20+ events in quick succession. If each of those events causes the images from multiple cameras to be captured, resized and redrawn, it’s possible that the application could get overloaded. When I did try that with my simple application it was able to cope, but then it only handles a single camera.