Fast way to create a QSurfaceDataArray from a numpy array
-
wrote on 23 Mar 2022, 12:43 last edited by
Is there a fast way to create a QSurfaceDataArray from a numpy array?
In the example for the Surface example, they added each point separately to the QSurfaceDataArray.
This is too slow for a live view with a lot of points.
In my case, the update of the 3D surface graph takes roughly 0.08s, which is acceptable. The parsing from a numpy array to a QSurfaceDataArray takes 10 times longer, which is an order too long. The problem is that I have to loop through the entire array and convert every point separately.It would be nice if there exist a vectorized parsing method. Maybe I could implement the code in C++ with the QVector3D C++ class. I never did this, and I don't know if it works, if I return a List of List s of QVector3D objects.
My code that is too slow:
def parse_data(data: np.ndarray): global vector_list for y_index in range(data.shape[0]): for x_index in range(data.shape[1]): vector_list[y_index][x_index] = QVector3D(x_index, data[y_index, x_index], y_index)
-
wrote on 31 Mar 2022, 10:18 last edited by
As far as I know Shiboken6 (the binding generator for PySide6) does support numpy array converters enabling direct conversion from Numpy arrays to C++ sequence containers. Maybe it is actually possible to do it.
Could you raise a feature suggestion for this here: https://wiki.qt.io/Qt_for_Python/Reporting_Bugs
The senior PySide6 developers would have an opinion on this.
-
wrote on 6 Apr 2022, 11:08 last edited by
Link to the opened suggestion report:
https://bugreports.qt.io/browse/PYSIDE-1880?jql=project %3D PYSIDE AND component %3D Shiboken