How can i reduce the execution time of "L3 Corner Track example" using my own video. I have observed in Vitis Analyzer that optical flow buffers are created in a loop which are adding more time to the execution process. I already managed to move other buffers of (pyr_down) to the beginning of the code so that they must not be created in a loop. But i am unable to move "Optical Flow" buffers out of the loop, if i do so, it does not give the correct optical flow. How this buffer can be managed?
I am executing a hardware build on "ZCU102"
Any leads?


for (int l = NUM_LEVELS - 1; l >= 0; l--)
{
// compute current level height
int curr_height = pyr_h[l];
int curr_width = pyr_w[l];
////////////////MOVED THESE BUFFERS OUT OF THE LOOP/////////////////WORKS FINE//////////////
in_img_py1_buf = cl::Buffer(context, CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
(pyr_h[l] * pyr_w[l] * CH_TYPE), (ap_uint<INPUT_PTR_WIDTH> *)imagepyr1[l].data);
in_img_py2_buf = cl::Buffer(context, CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
(pyr_h[l] * pyr_w[l] * CH_TYPE), (ap_uint<INPUT_PTR_WIDTH> *)imagepyr2[l].data);
/////////////////////////////////////////////////////////////////////////////////////////
in_img_py1_Vec.push_back(in_img_py1_buf);
in_img_py2_Vec.push_back(in_img_py2_buf);
q.enqueueMigrateMemObjects(in_img_py1_Vec, 0 /* 0 means from host*/);
q.enqueueMigrateMemObjects(in_img_py2_Vec, 0 /* 0 means from host*/);
/////////////////////////////UNABLE TO MOVE THIS////////////////////////////////////////
flow_buf = cl::Buffer(context, CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE, (pyr_h[l] * pyr_w[l] * 4),
(ap_uint<OUTPUT_PTR_WIDTH> *)flow.data);
////////////////////////////////////////////////////////////////////////////////////////////////////////
std::cout << "\n Buffers created" << std::endl;
// compute the flow vectors for the current pyramid level iteratively
std::cout << "\n *********OF Computation Level =" << l << "*********" << std::endl;
q.finish();
std::cout << "\n OF done" << std::endl;flow.init(pyr_h[l], pyr_w[l], 0);
flow_in.init(pyr_h[l], pyr_w[l], 0);