I have the following struct
which contains a data member pixeldata_
which is a pointer to an array of short ints. Size of this array is width * height.
struct Frame
{
public:
const uint16_t* getPixelData()
{
return this->pixeldata_;
}
int getWidth() { return this->width_; }
int getHeight(){ return this->height_; }
void setPixelData(const uint16_t* pixeldata)
{
this->pixeldata_ = pixeldata;
}
int getSize(){ return this->width_*this->height_; }
private:
const uint16_t* pixeldata_{nullptr};
int width_ {0}; // typically 640 for our use case
int height_{0}; // typically 480 for our use case
};
Using %include "stdint.i"
creates an opaque pointer of type SWIGTYPE_p_unsigned_short
which I cannot dereference. How can I copy that array into a Java container favorably an ArrayList of unsigned short
So, how would I wrap the following code for Java and access the member pixeldata_
and retrieve the array of short ints from C++ layer to Java containers?
Frame* Sensor::getFrame();
Frame* frame = getFrame();
auto pixel_data = frame->getPixelData();
for (auto pixel : pixel_data)
{
// possibly create an image or texture
}