TransWikia.com

Как эффективно преобразовать QImage в numpy.ndarray?

Stack Overflow на русском Asked by lirmon4ik on November 7, 2021

Как эффективно преобразовать QImage в numpy.ndarray?

Данный код неэффективен:

spisokPix = []
spisokPix2 = []
for y in range (self.currentPreview.height ()):
    spisokPix2.clear ()
    for x in range (self.currentPreview.width ()):
        color = self.currentPreview.pixelColor (x, y)
        spisokPix2.append (color.getRgb ()[:3][0])
    spisokPix.append (spisokPix2.copy ())
self.imageNda = np.array (spisokPix, np.uint8)

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP