0

I am looking for a way to convert a image, which is represented (because I used ArrayFire function loadimage()) as af::array to QVector. Any advice on how can I do this?

Thank you!

  • Hi and welcome to the community! What does the documentation for `QVector` indicate, how can such an object be instantiated? – Per Lundberg Nov 28 '18 at 21:46
  • It can be initialized: QVector(int size) QVector(int size, const T &value) QVector(const QVector &other) QVector(QVector &&other)... But I am not sure how to access elements within the af::array and to insert each to the vector. I am looking for something similar to the 2D array iteration with the 2 for loops and accessing particular element at ij position. – RandomUserIK Nov 28 '18 at 22:05
  • af::arrays can return a pointer to the memory using the [host](http://arrayfire.org/docs/group__method__mat.htm#ga332e06d4340867375a5e415fc1befc1d) member function. You can also write to an array using the same function by passing it in as a parameter. Check out the [getting started](http://arrayfire.org/docs/gettingstarted.htm) guide for simple use cases. – Umar Arshad Nov 29 '18 at 00:27
  • Possible duplicate of [Initialize QVector from array](https://stackoverflow.com/questions/38918772/initialize-qvector-from-array) – Per Lundberg Nov 29 '18 at 12:45

1 Answers1

0

Let a be you af::array. Provided you can retrieve the pointer to the actual data via a.host() and the number of array elements with a.bytes(), the question reduces to "How can I convert a C array to a QVector.

That is already answered here: Initialize QVector from array

jobor
  • 339
  • 1
  • 7