cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
cF Vitis Vision
cF » cFp » cFp_Zoo

This is the accelerated functions of Vitis Vision sub-library from Vitis Open Source Library. More...

Collaboration diagram for cF Vitis Vision:

Modules

 Harris
 This is the Harris accelerated function from Vitis Vision Open Source Library.
 
 Gammacorrection
 This is the Gammacorrection accelerated function from Vitis Vision Open Source Library.
 
 MedianBlur
 This is the MedianBlur accelerated function from Vitis Vision Open Source Library.
 
 Sobel
 This is the Sobel accelerated function from Vitis Vision Open Source Library.
 
 WarpTransform
 This is the WarpTransform accelerated function from Vitis Vision Open Source Library.
 

Macros

#define THIS_NAME   "TB"
 
#define TRACE_OFF   0x0000
 
#define TRACE_URIF   1 << 1
 
#define TRACE_UAF   1 << 2
 
#define TRACE_MMIO   1 << 3
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_ALL)
 
#define OK   true
 
#define KO   false
 
#define VALID   true
 
#define UNVALID   false
 
#define DEBUG_TRACE   true
 
#define ENABLED   (ap_uint<1>)1
 
#define DISABLED   (ap_uint<1>)0
 

Functions

bool setInputDataStream (stream< UdpWord > &sDataStream, const std::string dataStreamName, const std::string inpFileName, int simCnt)
 Initialize an input data stream from a file. More...
 
bool setInputFileToArray (const std::string inpFileName, ap_uint< OUTPUT_PTR_WIDTH > *imgArray, int simCnt)
 Initialize an input array from a file with format "tdata tkeep tlast". More...
 
bool readDataStream (stream< UdpWord > &sDataStream, UdpWord *udpWord)
 Read data from a stream. More...
 
ap_uint< 64 > pack_ap_uint_64_ (ap_uint< 8 > *buffer)
 Pack an array of 8 x ap_uint<8> into a ap_uint<64> word. More...
 
bool dumpDataToFile (UdpWord *udpWord, std::ofstream &outFileStream)
 Dump a data word to a file. More...
 
bool getOutputDataStream (stream< UdpWord > &sDataStream, const std::string dataStreamName, const std::string outFileName, int simCnt)
 Fill an output file with data from an output stream. More...
 
bool dumpImgToFile (xf::cv::Mat< OUT_TYPE, HEIGHT, WIDTH, NPIX > &_img, const std::string outFileName, int simCnt)
 Fill an output file with data from an image. More...
 
unsigned int writeCornersIntoFile (cv::Mat &in_img, cv::Mat &ocv_out_img, cv::Mat &out_img, std::vector< cv::Point > &hls_points, std::vector< cv::Point > &ocv_points, std::vector< cv::Point > &common_pts)
 Write the corners found by Harris into a file. More...
 
void markPointsOnImage (xf::cv::Mat< OUT_TYPE, HEIGHT, WIDTH, NPIX > &imgOutput, cv::Mat &in_img, cv::Mat &out_img, std::vector< cv::Point > &hls_points)
 Mark the points found by Harris into the image. More...
 
bool setInputDataStream (stream< UdpWord > &sDataStream, const string dataStreamName, const string inpFileName, int simCnt)
 Initialize an input data stream from a file. More...
 
bool setInputFileToArray (const string inpFileName, ap_uint< OUTPUT_PTR_WIDTH > *imgArray, int simCnt)
 Initialize an input array from a file with format "tdata tkeep tlast". More...
 
bool dumpDataToFile (UdpWord *udpWord, ofstream &outFileStream)
 Dump a data word to a file. More...
 
bool getOutputDataStream (stream< UdpWord > &sDataStream, const string dataStreamName, const string outFileName, int simCnt)
 Fill an output file with data from an output stream. More...
 
bool dumpImgToFile (xf::cv::Mat< OUT_TYPE, HEIGHT, WIDTH, NPIX > &_img, const string outFileName, int simCnt)
 Fill an output file with data from an image. More...
 
bool dumpImgToFileWarpTransform (xf::cv::Mat< OUT_TYPE, HEIGHT, WIDTH, NPIX > &_img, const string outFileName, int simCnt, float *transform_matrix)
 Fill an output file with data from an image. More...
 

Detailed Description

This is the accelerated functions of Vitis Vision sub-library from Vitis Open Source Library.

cFDK / cFp / cFp_Zoo : Submodules

Macro Definition Documentation

◆ DEBUG_LEVEL

#define DEBUG_LEVEL   (TRACE_ALL)

Definition at line 63 of file common.hpp.

◆ DEBUG_TRACE

#define DEBUG_TRACE   true

Definition at line 73 of file common.hpp.

◆ DISABLED

#define DISABLED   (ap_uint<1>)0

Definition at line 76 of file common.hpp.

◆ ENABLED

#define ENABLED   (ap_uint<1>)1

Definition at line 75 of file common.hpp.

◆ KO

#define KO   false

Definition at line 70 of file common.hpp.

◆ OK

#define OK   true

Definition at line 69 of file common.hpp.

◆ THIS_NAME

#define THIS_NAME   "TB"

Definition at line 55 of file common.hpp.

◆ TRACE_ALL

#define TRACE_ALL   0xFFFF

Definition at line 61 of file common.hpp.

◆ TRACE_MMIO

#define TRACE_MMIO   1 << 3

Definition at line 60 of file common.hpp.

◆ TRACE_OFF

#define TRACE_OFF   0x0000

Definition at line 57 of file common.hpp.

◆ TRACE_UAF

#define TRACE_UAF   1 << 2

Definition at line 59 of file common.hpp.

◆ TRACE_URIF

#define TRACE_URIF   1 << 1

Definition at line 58 of file common.hpp.

◆ UNVALID

#define UNVALID   false

Definition at line 72 of file common.hpp.

◆ VALID

#define VALID   true

Definition at line 71 of file common.hpp.

Function Documentation

◆ dumpDataToFile() [1/2]

bool dumpDataToFile ( UdpWord udpWord,
ofstream &  outFileStream 
)

Dump a data word to a file.

Parameters
[in]udpWord,apointer to the data word to dump.
[in]outFileStream,theoutput file stream to write to.
Returns
OK if successful, otherwise KO.

Definition at line 174 of file common.cpp.

174  {
175  if (!outFileStream.is_open()) {
176  printf("### ERROR : Output file stream is not open. \n");
177  return(KO);
178  }
179  outFileStream << hex << noshowbase << setfill('0') << setw(16) << udpWord->tdata.to_uint64();
180  outFileStream << " ";
181  outFileStream << hex << noshowbase << setfill('0') << setw(2) << udpWord->tkeep.to_int();
182  outFileStream << " ";
183  outFileStream << setw(1) << udpWord->tlast.to_int() << "\n";
184  return(OK);
185 }
#define OK
Definition: nts_types.hpp:57
#define KO
Definition: nts_types.hpp:58
ap_uint< 64 > tdata
ap_uint< 1 > tlast
ap_uint< 8 > tkeep

◆ dumpDataToFile() [2/2]

bool dumpDataToFile ( UdpWord udpWord,
std::ofstream &  outFileStream 
)

Dump a data word to a file.

Parameters
[in]udpWord,apointer to the data word to dump.
[in]outFileStream,theoutput file stream to write to.
Returns
OK if successful, otherwise KO.

◆ dumpImgToFile() [1/2]

bool dumpImgToFile ( xf::cv::Mat< OUT_TYPE, HEIGHT, WIDTH, NPIX > &  _img,
const std::string  outFileName,
int  simCnt 
)

Fill an output file with data from an image.

Parameters
[in]sDataStreamthe input image in xf::cv::Mat format.
[in]outFileNamethe name of the output file to write to.
Returns
OK if successful, otherwise KO.
Here is the caller graph for this function:

◆ dumpImgToFile() [2/2]

bool dumpImgToFile ( xf::cv::Mat< OUT_TYPE, HEIGHT, WIDTH, NPIX > &  _img,
const string  outFileName,
int  simCnt 
)

Fill an output file with data from an image.

Parameters
[in]sDataStreamthe input image in xf::cv::Mat format.
[in]outFileNamethe name of the output file to write to.
Returns
OK if successful, otherwise KO.

Definition at line 240 of file common.cpp.

242 {
243  string strLine;
244  ofstream outFileStream;
245  string datFile = "../../../../test/" + outFileName;
246  UdpWord udpWord;
247  bool rc = OK;
248  unsigned int bytes_per_line = 8;
249 
250  //-- STEP-1 : OPEN FILE
251  outFileStream.open(datFile.c_str());
252  if ( !outFileStream ) {
253  cout << "### ERROR : Could not open the output data file " << datFile << endl;
254  return(KO);
255  }
256  printf("came to dumpImgToFile: _img.rows=%u, img.cols=%u\n", _img.rows, _img.cols);
257 
258  ap_uint<8> value[bytes_per_line];
259 
260  //-- STEP-2 : DUMP IMAGE DATA TO FILE
261  for (unsigned int total_bytes = 0, chan =0 ; chan < _img.channels(); chan++) {
262  for (unsigned int j = 0; j < _img.rows; j++) {
263  int l = 0;
264  for (unsigned int i = 0; i < (_img.cols >> XF_BITSHIFT(NPIX)); i+=bytes_per_line, total_bytes+=bytes_per_line) {
265  //if (NPIX == XF_NPPC8) {
266  for (unsigned int k = 0; k < bytes_per_line; k++) {
267  value[k] = _img.read(j * (_img.cols >> XF_BITSHIFT(NPIX)) + i + k);
268  }
269  udpWord.tdata = pack_ap_uint_64_(value);
270  udpWord.tkeep = 255;
271  // We are signaling a packet termination either at the end of the image or the end of MTU
272  if ((total_bytes >= (_img.rows * _img.cols * _img.channels() - bytes_per_line)) ||
273  ((total_bytes + bytes_per_line) % PACK_SIZE == 0)) {
274  udpWord.tlast = 1;
275  }
276  else {
277  udpWord.tlast = 0;
278  }
279  printf("[%4.4d] IMG TB is dumping image to file [%s] - Data read [%u] = {val=%u, D=0x%16.16llX, K=0x%2.2X, L=%d} \n",
280  simCnt, datFile.c_str(), total_bytes, value,
281  udpWord.tdata.to_long(), udpWord.tkeep.to_int(), udpWord.tlast.to_int());
282  if (!dumpDataToFile(&udpWord, outFileStream)) {
283  rc = KO;
284  break;
285  }
286  //}
287  }
288  }
289  }
290  //-- STEP-3: CLOSE FILE
291  outFileStream.close();
292 
293  return(rc);
294 }
int simCnt
Definition: tb_fmc.cpp:113
#define NPIX
ap_uint< 64 > pack_ap_uint_64_(ap_uint< 8 > *buffer)
Pack an array of 8 x ap_uint<8> into a ap_uint<64> word.
Definition: common.cpp:116
bool dumpDataToFile(UdpWord *udpWord, ofstream &outFileStream)
Dump a data word to a file.
Definition: common.cpp:153
#define PACK_SIZE
Definition: config.h:51
Here is the call graph for this function:

◆ dumpImgToFileWarpTransform()

bool dumpImgToFileWarpTransform ( xf::cv::Mat< OUT_TYPE, HEIGHT, WIDTH, NPIX > &  _img,
const string  outFileName,
int  simCnt,
float *  transform_matrix 
)

Fill an output file with data from an image.

Parameters
[in]sDataStreamthe input image in xf::cv::Mat format.
[in]outFileNamethe name of the output file to write to.
Returns
OK if successful, otherwise KO.

Definition at line 304 of file common.cpp.

306 {
307  string strLine;
308  ofstream outFileStream;
309  string datFile = "../../../../test/" + outFileName;
310  UdpWord udpWord;
311  bool rc = OK;
312  unsigned int bytes_per_line = 8;
313 
314  //-- STEP-1 : OPEN FILE
315  outFileStream.open(datFile.c_str());
316  if ( !outFileStream ) {
317  cout << "### ERROR : Could not open the output data file " << datFile << endl;
318  return(KO);
319  }
320  printf("came to dumpImgToFile: _img.rows=%u, img.cols=%u\n", _img.rows, _img.cols);
321 
322  ap_uint<8> value[bytes_per_line];
323  ap_uint<8> tx_cmd[bytes_per_line];
324  ap_uint<8> img_cmd[bytes_per_line];
325  //init tx and img cmd
326  for (unsigned int k = 0; k < bytes_per_line; k++) {
327  value[k] = (char)0;
328  if (k != 0) {
329  tx_cmd[k] = (char)0;
330  img_cmd[k] = (char)0;
331  }
332  else {
333  tx_cmd[k] = (char)1;
334  img_cmd[k] = (char)2;
335  }
336  }
337 
338  //dump tx cmd
339  udpWord.tdata = pack_ap_uint_64_(tx_cmd);
340  udpWord.tkeep = 255;
341  udpWord.tlast = 0;
342  if (!dumpDataToFile(&udpWord, outFileStream)) {
343  rc = KO;
344  outFileStream.close();
345  return(rc);
346  }
347  int off = 4;
348  for (int i = 0; i < 8; i++)
349  {
350  memcpy(value+off, (float*)transform_matrix+i, 4);
351  off += 4;
352  off = off % bytes_per_line;
353  std::cout << "[DEBUG] off=" << off << " tx mat=" << transform_matrix[i] << " idx=" << i << " flt val=" << value[off] << " " << value[off+1] << " " << value[off+2] << " " << value[off+3]<< std::endl;
354  if (i%2 && i!=0)
355  {
356  std::cout << "[DEBUG] packing the valua :D" << std::endl;
357  udpWord.tdata = pack_ap_uint_64_(value);
358  udpWord.tkeep = 255;
359  udpWord.tlast = 0;
360  if (!dumpDataToFile(&udpWord, outFileStream)) {
361  rc = KO;
362  outFileStream.close();
363  return(rc);
364  }
365  }
366 
367  }
368 
369  //dump last value
370  unsigned int zero_constant = 0;
371  memcpy(value, (char*)transform_matrix+8, 4);
372  memcpy(value, (char*)&zero_constant, 4);
373  udpWord.tdata = pack_ap_uint_64_(value);
374  udpWord.tkeep = 255;
375  udpWord.tlast = 0;
376  if (!dumpDataToFile(&udpWord, outFileStream)) {
377  rc = KO;
378  outFileStream.close();
379  return(rc);
380  }
381 
382  //creating img mat cmd
383  memcpy(img_cmd+6, (char*)&_img.rows, 2);
384  memcpy(img_cmd+4, (char*)&_img.cols, 2);
385  img_cmd[1]=_img.channels();
386 
387  udpWord.tdata = pack_ap_uint_64_(img_cmd);
388  udpWord.tkeep = 255;
389  udpWord.tlast = 0;
390  if (!dumpDataToFile(&udpWord, outFileStream)) {
391  rc = KO;
392  outFileStream.close();
393  return(rc);
394  }
395  //-- STEP-2 : DUMP IMAGE DATA TO FILE
396  for (unsigned int total_bytes = 0, chan =0 ; chan < _img.channels(); chan++) {
397  for (unsigned int j = 0; j < _img.rows; j++) {
398  int l = 0;
399  for (unsigned int i = 0; i < (_img.cols >> XF_BITSHIFT(NPIX)); i+=bytes_per_line, total_bytes+=bytes_per_line) {
400  //if (NPIX == XF_NPPC8) {
401  for (unsigned int k = 0; k < bytes_per_line; k++) {
402  value[k] = _img.read(j * (_img.cols >> XF_BITSHIFT(NPIX)) + i + k);
403  }
404  udpWord.tdata = pack_ap_uint_64_(value);
405  udpWord.tkeep = 255;
406  // We are signaling a packet termination either at the end of the image or the end of MTU
407  if ((total_bytes >= (_img.rows * _img.cols * _img.channels() - bytes_per_line)) ||
408  ((total_bytes + bytes_per_line) % PACK_SIZE == 0)) {
409  udpWord.tlast = 1;
410  }
411  else {
412  udpWord.tlast = 0;
413  }
414  printf("[%4.4d] IMG TB is dumping image to file [%s] - Data read [%u] = {val=%u, D=0x%16.16llX, K=0x%2.2X, L=%d} \n",
415  simCnt, datFile.c_str(), total_bytes, value,
416  udpWord.tdata.to_long(), udpWord.tkeep.to_int(), udpWord.tlast.to_int());
417  if (!dumpDataToFile(&udpWord, outFileStream)) {
418  rc = KO;
419  break;
420  }
421  //}
422  }
423  }
424  }
425  //-- STEP-3: CLOSE FILE
426  outFileStream.close();
427 
428  return(rc);
429 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOutputDataStream() [1/2]

bool getOutputDataStream ( stream< UdpWord > &  sDataStream,
const std::string  dataStreamName,
const std::string  outFileName,
int  simCnt 
)

Fill an output file with data from an output stream.

Parameters
[in]sDataStream,theoutput data stream to set.
[in]dataStreamName,thename of the data stream.
[in]outFileName,thename of the output file to write to.
Returns
OK if successful, otherwise KO.

◆ getOutputDataStream() [2/2]

bool getOutputDataStream ( stream< UdpWord > &  sDataStream,
const string  dataStreamName,
const string  outFileName,
int  simCnt 
)

Fill an output file with data from an output stream.

Parameters
[in]sDataStream,theoutput data stream to set.
[in]dataStreamName,thename of the data stream.
[in]outFileName,thename of the output file to write to.
Returns
OK if successful, otherwise KO.

Definition at line 196 of file common.cpp.

198 {
199  string strLine;
200  ofstream outFileStream;
201  string datFile = "../../../../test/" + outFileName;
202  UdpWord udpWord;
203  bool rc = OK;
204 
205  //-- STEP-1 : OPEN FILE
206  outFileStream.open(datFile.c_str());
207  if ( !outFileStream ) {
208  cout << "### ERROR : Could not open the output data file " << datFile << endl;
209  return(KO);
210  }
211 
212  //-- STEP-2 : EMPTY STREAM AND DUMP DATA TO FILE
213  while (!sDataStream.empty()) {
214  if (readDataStream(sDataStream, &udpWord) == VALID) {
215  // Print DUT/Data to console
216  printf("[%4.4d] TB is draining output stream [%s] - Data read = {D=0x%16.16llX, K=0x%2.2X, L=%d} \n",
217  simCnt, dataStreamName.c_str(),
218  udpWord.tdata.to_long(), udpWord.tkeep.to_int(), udpWord.tlast.to_int());
219  if (!dumpDataToFile(&udpWord, outFileStream)) {
220  rc = KO;
221  break;
222  }
223  }
224  }
225 
226  //-- STEP-3: CLOSE FILE
227  outFileStream.close();
228 
229  return(rc);
230 }
bool readDataStream(stream< UdpAppData > &sDataStream, UdpAppData *udpWord)
Read data from a stream.
Definition: tb_nal.cpp:395
#define VALID
Definition: tb_nal.cpp:43
Here is the call graph for this function:

◆ markPointsOnImage()

void markPointsOnImage ( xf::cv::Mat< OUT_TYPE, HEIGHT, WIDTH, NPIX > &  imgOutput,
cv::Mat &  in_img,
cv::Mat &  out_img,
std::vector< cv::Point > &  hls_points 
)

Mark the points found by Harris into the image.

Returns
Nothing

Definition at line 506 of file common.cpp.

507  {
508 
509  for (int j = 0; j < imgOutput.rows; j++) {
510  int l = 0;
511  for (int i = 0; i < (imgOutput.cols >> XF_BITSHIFT(NPIX)); i++) {
512  if (NPIX == XF_NPPC8) {
513  ap_uint<64> value =
514  imgOutput.read(j * (imgOutput.cols >> XF_BITSHIFT(NPIX)) + i); //.at<unsigned char>(j,i);
515  for (int k = 0; k < 64; k += 8, l++) {
516  uchar pix = value.range(k + 7, k);
517  if (pix != 0) {
518  cv::Point tmp;
519  tmp.x = l;
520  tmp.y = j;
521  if ((tmp.x < in_img.cols) && (tmp.y < in_img.rows) && (j > 0)) {
522  hls_points.push_back(tmp);
523  }
524  short int y, x;
525  y = j;
526  x = l;
527  if (j > 0) cv::circle(out_img, cv::Point(x, y), 5, cv::Scalar(0, 0, 255, 255), 2, 8, 0);
528  }
529  }
530  }
531  if (NPIX == XF_NPPC1) {
532  unsigned char pix = imgOutput.read(j * (imgOutput.cols >> XF_BITSHIFT(NPIX)) + i);
533  if (pix != 0) {
534  cv::Point tmp;
535  tmp.x = i;
536  tmp.y = j;
537  if ((tmp.x < in_img.cols) && (tmp.y < in_img.rows) && (j > 0)) {
538  hls_points.push_back(tmp);
539  }
540  short int y, x;
541  y = j;
542  x = i;
543  if (j > 0) cv::circle(out_img, cv::Point(x, y), 5, cv::Scalar(0, 0, 255, 255), 2, 8, 0);
544  }
545  }
546  }
547  }
548 }

◆ pack_ap_uint_64_()

ap_uint<64> pack_ap_uint_64_ ( ap_uint< 8 > *  buffer)

Pack an array of 8 x ap_uint<8> into a ap_uint<64> word.

Parameters
[in]bufferA pointer to an array of 8 x ap_uint<8>
Returns
An ap_uint<64> word.

Definition at line 150 of file common.cpp.

150  {
151 
152  ap_uint<64> value ;
153 
154  value = buffer[7] ;
155  value = (value << 8 ) + buffer[6] ;
156  value = (value << 8 ) + buffer[5] ;
157  value = (value << 8 ) + buffer[4] ;
158  value = (value << 8 ) + buffer[3] ;
159  value = (value << 8 ) + buffer[2] ;
160  value = (value << 8 ) + buffer[1] ;
161  value = (value << 8 ) + buffer[0] ;
162 
163  return value ;
164 
165 }

◆ readDataStream()

bool readDataStream ( stream< UdpWord > &  sDataStream,
UdpWord udpWord 
)

Read data from a stream.

Parameters
[in]sDataStream,theoutput data stream to read.
[in]dataStreamName,thename of the data stream.
[out]udpWord,apointer to the storage location of the data to read.
Returns
VALID if a data was read, otherwise UNVALID.

Definition at line 137 of file common.cpp.

137  {
138  // Get the DUT/Data results
139  sDataStream.read(*udpWord);
140  return(VALID);
141 }

◆ setInputDataStream() [1/2]

bool setInputDataStream ( stream< UdpWord > &  sDataStream,
const std::string  dataStreamName,
const std::string  inpFileName,
int  simCnt 
)

Initialize an input data stream from a file.

Parameters
[in]sDataStreamthe input data stream to set.
[in]dataStreamNamethe name of the data stream.
[in]inpFileNamethe name of the input file to read from.
Returns
OK if successful otherwise KO.

◆ setInputDataStream() [2/2]

bool setInputDataStream ( stream< UdpWord > &  sDataStream,
const string  dataStreamName,
const string  inpFileName,
int  simCnt 
)

Initialize an input data stream from a file.

Parameters
[in]sDataStreamthe input data stream to set.
[in]dataStreamNamethe name of the data stream.
[in]inpFileNamethe name of the input file to read from.
Returns
OK if successful otherwise KO.

Definition at line 33 of file common.cpp.

34  {
35  string strLine;
36  ifstream inpFileStream;
37  string datFile = "../../../../test/" + inpFileName;
38  UdpWord udpWord;
39 
40  //-- STEP-1 : OPEN FILE
41  inpFileStream.open(datFile.c_str());
42  if ( !inpFileStream ) {
43  cout << "### ERROR : Could not open the input data file " << datFile << endl;
44  return(KO);
45  }
46 
47  //-- STEP-2 : SET DATA STREAM
48  while (inpFileStream) {
49 
50  if (!inpFileStream.eof()) {
51 
52  getline(inpFileStream, strLine);
53  if (strLine.empty()) continue;
54  sscanf(strLine.c_str(), "%llx %x %d", &udpWord.tdata, &udpWord.tkeep, &udpWord.tlast);
55 
56  // Write to sDataStream
57  if (sDataStream.full()) {
58  printf("### ERROR : Stream is full. Cannot write stream with data from file \"%s\".\n", inpFileName.c_str());
59  return(KO);
60  } else {
61  sDataStream.write(udpWord);
62  // Print Data to console
63  printf("[%4.4d] TB is filling input stream [%s] - Data write = {D=0x%16.16llX, K=0x%2.2X, L=%d} \n",
64  simCnt, dataStreamName.c_str(),
65  udpWord.tdata.to_long(), udpWord.tkeep.to_int(), udpWord.tlast.to_int());
66  }
67  }
68  }
69 
70  //-- STEP-3: CLOSE FILE
71  inpFileStream.close();
72 
73  return(OK);
74 }

◆ setInputFileToArray() [1/2]

bool setInputFileToArray ( const std::string  inpFileName,
ap_uint< OUTPUT_PTR_WIDTH > *  imgArray,
int  simCnt 
)

Initialize an input array from a file with format "tdata tkeep tlast".

Parameters
[in]inpFileNamethe name of the input file to read from.
[out]imgOutputArraythe array to write the tdata only field from the file.
Returns
OK if successful otherwise KO.
Here is the caller graph for this function:

◆ setInputFileToArray() [2/2]

bool setInputFileToArray ( const string  inpFileName,
ap_uint< OUTPUT_PTR_WIDTH > *  imgArray,
int  simCnt 
)

Initialize an input array from a file with format "tdata tkeep tlast".

Parameters
[in]inpFileNamethe name of the input file to read from.
[out]imgArraythe array to write the tdata only field from the file.
Returns
OK if successful otherwise KO.

Definition at line 85 of file common.cpp.

85  {
86  string strLine;
87  ifstream inpFileStream;
88  string datFile = "../../../../test/" + inpFileName;
89  UdpWord udpWord;
90  unsigned int index = 0;
91  ap_uint<OUTPUT_PTR_WIDTH> current_tdata;
92 
93  //-- STEP-1 : OPEN FILE
94  inpFileStream.open(datFile.c_str());
95  if ( !inpFileStream ) {
96  cout << "### ERROR : Could not open the input data file " << datFile << endl;
97  return(KO);
98  }
99 
100  //-- STEP-2 : SET DATA STREAM
101  while (inpFileStream) {
102 
103  if (!inpFileStream.eof()) {
104 
105  getline(inpFileStream, strLine);
106  if (strLine.empty()) continue;
107  sscanf(strLine.c_str(), "%llx %x %d", &udpWord.tdata, &udpWord.tkeep, &udpWord.tlast);
108  for (unsigned int i=0; i<(BITS_PER_10GBITETHRNET_AXI_PACKET/OUTPUT_PTR_WIDTH); i++) {
109  current_tdata = (ap_uint<OUTPUT_PTR_WIDTH>)(udpWord.tdata >> i*8);//FIXME: check
110  // possible seg.fault
111  imgArray[index++] = current_tdata;
112  // Print Data to console
113  printf("[%4.4d] TB is filling input array from [%s] - Data write = {D=0x%16.16llX, K=0x%2.2X, L=%d, current_tdata=0x%16.16llX} \n",
114  simCnt, inpFileName.c_str(),
115  udpWord.tdata.to_long(), udpWord.tkeep.to_int(), udpWord.tlast.to_int(),
116  current_tdata.to_long());
117  }
118  }
119  }
120 
121  //-- STEP-3: CLOSE FILE
122  inpFileStream.close();
123 
124  return(OK);
125 }
#define BITS_PER_10GBITETHRNET_AXI_PACKET
#define OUTPUT_PTR_WIDTH

◆ writeCornersIntoFile()

unsigned int writeCornersIntoFile ( cv::Mat &  in_img,
cv::Mat &  ocv_out_img,
cv::Mat &  out_img,
std::vector< cv::Point > &  hls_points,
std::vector< cv::Point > &  ocv_points,
std::vector< cv::Point > &  common_pts 
)

Write the corners found by Harris into a file.

Returns
0 if successful, otherwise 1.

Drawing a circle around corners

Definition at line 437 of file common.cpp.

440  {
441 
442  cv::Mat ocvpnts, hlspnts;
443 
444  ocvpnts = in_img.clone();
445 
446  int nhls = hls_points.size();
447 
449  for (int j = 1; j < ocv_out_img.rows - 1; j++) {
450  for (int i = 1; i < ocv_out_img.cols - 1; i++) {
451  if ((int)ocv_out_img.at<unsigned char>(j, i)) {
452  cv::circle(ocvpnts, cv::Point(i, j), 5, cv::Scalar(0, 0, 255), 2, 8, 0);
453  ocv_points.push_back(cv::Point(i, j));
454  }
455  }
456  }
457 
458  printf("ocv corner count = %d, Hls corner count = %d\n", ocv_points.size(), hls_points.size());
459  int nocv = ocv_points.size();
460 
461  /* End
462  */
463  /* Find common points in among opencv and HLS
464  */
465  int ocv_x, ocv_y, hls_x, hls_y;
466  for (int j = 0; j < nocv; j++) {
467  for (int k = 0; k < nhls; k++) {
468  ocv_x = ocv_points[j].x;
469  ocv_y = ocv_points[j].y;
470  hls_x = hls_points[k].x;
471  hls_y = hls_points[k].y;
472 
473  if ((ocv_x == hls_x) && (ocv_y == hls_y)) {
474  common_pts.push_back(ocv_points[j]);
475  break;
476  }
477  }
478  }
479  /* End */
480  imwrite("output_hls.png", out_img); // HLS Image
481  imwrite("output_ocv.png", ocvpnts); // Opencv Image
482  /* Success, Loss and Gain Percentages */
483  float persuccess, perloss, pergain;
484 
485  int totalocv = ocv_points.size();
486  int ncommon = common_pts.size();
487  int totalhls = hls_points.size();
488  persuccess = (((float)ncommon / totalhls) * 100);
489  perloss = (((float)(totalocv - ncommon) / totalocv) * 100);
490  pergain = (((float)(totalhls - ncommon) / totalhls) * 100);
491 
492  printf("Commmon = %d\t Success = %f\t Loss = %f\t Gain = %f\n", ncommon, persuccess, perloss, pergain);
493 
494  if (persuccess < 60 || totalhls == 0)
495  return 1;
496  else
497  return 0;
498 
499 }
Here is the caller graph for this function: