Use vision function Flip in Pynq-HelloWorld?

Hello,

I am trying to convert Pynq-HelloWorld to use flip instead of resize.

I notice that some functions, like flip, have a different input/output definition. Like in vision/L1/include/imgproc/xf_flip.hpp:
template <int PTR_WIDTH, int TYPE, int ROWS, int COLS, int NPC>
void flip(ap_uint<PTR_WIDTH>* SrcPtr,
ap_uint<PTR_WIDTH>* DstPtr,
int Rows,
int Cols,
int Direction){

versus the resize:

void resize(xf::cv::Mat<TYPE, SRC_ROWS, SRC_COLS, NPC>& _src, xf::cv::Mat<TYPE, DST_ROWS, DST_COLS, NPC>& _dst)

The flip function requires an input different than the resize function, which wants a templated xf:cv:Mat. Does this mean that the flip function operates on the full image?

Is there a way to use these in the Pynq-HelloWorld framework?

Thanks,
John

1 Like

Hi John,
You may be better asking questions related to the Vitis libraries on the Xilinx forums or on the GitHub for issues.
In short I think your observations are correct - flip operates (or can operate) on a full image.

The xf::cv::Mat is a container that makes it more convenient to work with image types and streams. As you point out, the input/output types for xf_flip are ap_uint<PTR_WIDTH>*
The other functions that use MAT (in general?) operate on a stream of data. There may be some pixel or line buffering, but it is still a stream. i.e you don’t need to buffer or store the whole image. If you do a vertical & horizontal flip you need to buffer a full image. I’m assuming this is why it is implemented like this.

If you only need the flip(), then if you look at the hello world code you can see the input to the top level function is actually a pointer, and this type is converted to a MAT. You wouldn’t need this conversion to MAT, but you would need to manage the image attributes manually.

The important part here is that you will have a memory interface to your src/dest as is done in PYNQ hello world. You wouldn’t be able to implement this as an AXI stream.

However, if you want to combine flip() with other functions that use MAT types I think you would need to convert back and forth between the MAT and array pointer and you would need to store the image which isn’t convenient but I’m not sure if there is a better way to do this.

Cathal

Thanks so much for the information and suggestions. I will try to implement it without the stream conversion for now to get experience.

Flip isn’t an important function for me but is representative of things I can’t use the same conversions and matrices.

Have a great day,
John