20 #include "../../common/src/common.cpp" 
   28 #define THIS_NAME "TB" 
   30 #define TRACE_OFF     0x0000 
   31 #define TRACE_URIF   1 <<  1 
   32 #define TRACE_UAF    1 <<  2 
   33 #define TRACE_MMIO   1 <<  3 
   34 #define TRACE_ALL     0xFFFF 
   36 #define DEBUG_LEVEL (TRACE_ALL) 
   46 #define DEBUG_TRACE true 
   48 #define ENABLED     (ap_uint<1>)1 
   49 #define DISABLED    (ap_uint<1>)0 
   89     printf(
"[%4.4d] STEP DUT \n", 
simCnt);
 
  100 int main(
int argc, 
char** argv) {
 
  107     printf(
"#####################################################\n");
 
  108     printf(
"## TESTBENCH STARTS HERE                           ##\n");
 
  109     printf(
"#####################################################\n");
 
  117     cv::Mat in_img, img_gray;
 
  118     cv::Mat hls_out_img, ocv_out_img;
 
  121         printf(
"Usage : %s <input image> \n", argv[0]);
 
  124     in_img = cv::imread(argv[1], 0); 
 
  127         printf(
"Failed to load the image ... %s\n!", argv[1]);
 
  131       printf(
"Succesfully loaded image ... %s\n!", argv[1]);
 
  143         Th = 41151168289701888.000000;
 
  153     hls_out_img.create(in_img.rows, in_img.cols, CV_8U); 
 
  154     ocv_out_img.create(in_img.rows, in_img.cols, CV_8U); 
 
  158     static xf::cv::Mat<IN_TYPE, HEIGHT, WIDTH, XF_NPPC1> imgInput(in_img.rows, in_img.cols);
 
  159     static xf::cv::Mat<IN_TYPE, HEIGHT, WIDTH, XF_NPPC1> imgOutput(in_img.rows, in_img.cols);
 
  160     static xf::cv::Mat<IN_TYPE, HEIGHT, WIDTH, XF_NPPC1> imgOutputTb(in_img.rows, in_img.cols);
 
  162     imgInput.copyTo(in_img.data);
 
  165     ap_uint<INPUT_PTR_WIDTH> imgInputArray[in_img.rows * in_img.cols];
 
  166     ap_uint<OUTPUT_PTR_WIDTH> imgOutputArrayTb[in_img.rows * in_img.cols];
 
  167     ap_uint<OUTPUT_PTR_WIDTH> imgOutputArray[in_img.rows * in_img.cols];
 
  169     xf::cv::xfMat2Array<OUTPUT_PTR_WIDTH, IN_TYPE, HEIGHT, WIDTH, NPIX>(imgInput, imgInputArray);
 
  179     static xf::cv::Mat<IN_TYPE, HEIGHT, WIDTH, XF_NPPC8> imgInput(in_img.rows, in_img.cols);
 
  180     static xf::cv::Mat<IN_TYPE, HEIGHT, WIDTH, XF_NPPC8> imgOutput(in_img.rows, in_img.cols);
 
  181     static xf::cv::Mat<IN_TYPE, HEIGHT, WIDTH, XF_NPPC1> imgOutputTb(in_img.rows, in_img.cols);
 
  184     imgInput = xf::cv::imread<IN_TYPE, HEIGHT, WIDTH, XF_NPPC8>(argv[1], 0);
 
  193     ocv_ref(in_img, ocv_out_img, Th);
 
  201             printf(
"### ERROR : Failed to set input data stream \"sSHL_Uaf_Data\". \n");
 
  245             printf(
"## End of simulation at cycle=%3d. \n", 
simCnt);
 
  267         printf(
"NRC received NRCmeta stream from rank %d to rank %d.\n", (
int) tmp_meta.
tdata.
src_rank, (
int) tmp_meta.
tdata.
dst_rank);
 
  275       printf(
"Error No metadata received...\n");
 
  283       printf(
"### ERROR : Failed to set input array from file \"ofsUAF_Shl_Data.dat\". \n");
 
  286     xf::cv::Array2xfMat<INPUT_PTR_WIDTH, OUT_TYPE, HEIGHT, WIDTH, NPIX>(imgOutputArray, imgOutput);
 
  292     int rc1 = system(
"diff --brief -w -i -y ../../../../test/ofsUAF_Shl_Data.dat \ 
  293                                             ../../../../test/verify_UAF_Shl_Data.dat");
 
  296         printf(
"## Error : File \'ofsUAF_Shl_Data.dat\' does not match \'verify_UAF_Shl_Data.dat\'.\n");
 
  298       printf(
"Output data in file \'ofsUAF_Shl_Data.dat\' verified.\n");
 
  303     printf(
"#####################################################\n");
 
  306         printf(
"## ERROR - TESTBENCH FAILED (RC=%d) !!!             ##\n", nrErr);
 
  308         printf(
"## SUCCESSFULL END OF TESTBENCH (RC=0)             ##\n");
 
  310     printf(
"#####################################################\n");
 
  326     uint16_t k = K * (1 << 16); 
 
  332     xf::cv::Array2xfMat<INPUT_PTR_WIDTH, OUT_TYPE, HEIGHT, WIDTH, NPIX>(imgOutputArrayTb, imgOutputTb);
 
  346     xf::cv::imwrite(
"hls_out_tb.jpg", imgOutputTb);
 
  347     xf::cv::imwrite(
"hls_out.jpg", imgOutput);
 
  350     unsigned short int row, col;
 
  353     out_img = in_img.clone();
 
  355     std::vector<cv::Point> hls_points;
 
  356     std::vector<cv::Point> ocv_points;
 
  357     std::vector<cv::Point> common_pts;
 
  359     xf::cv::Mat<OUT_TYPE, HEIGHT, WIDTH, NPIX>* select_imgOutput;
 
  364     select_imgOutput = &imgOutput;
 
  374     xf::cv::imwrite(
"gammacorrection_in_hls.jpg", imgInput);
 
  376     xf::cv::imwrite(
"gammacorrection_out_hls.jpg", imgOutput);
 
void gammacorrection(ap_uint< 32 > *pi_rank, ap_uint< 32 > *pi_size, stream< NetworkWord > &siSHL_This_Data, stream< NetworkWord > &soTHIS_Shl_Data, stream< NetworkMetaStream > &siNrc_meta, stream< NetworkMetaStream > &soNrc_meta, ap_uint< 32 > *po_rx_ports)
Main process of the Gammacorrection Application directives.
 
stream< NetworkMetaStream > siUdp_meta("siUdp_meta")
 
int main(int argc, char **argv)
Main testbench of Hrris.
 
stream< NetworkMetaStream > soUdp_meta("soUdp_meta")
 
void ocv_ref(cv::Mat img_gray, cv::Mat &ocv_out_img, float Th)
 
ap_uint< 1 > piSHL_This_MmioCaptPktEn
 
ap_uint< 1 > piSHL_This_MmioPostPktEn
 
stream< UdpWord > sUAF_Shl_Data("sUAF_Shl_Data")
 
void stepDut()
Run a single iteration of the DUT model.
 
stream< UdpWord > image_stream_from_gammacorrection("image_stream_from_gammacorrection")
 
stream< UdpWord > sSHL_Uaf_Data("sSHL_Uaf_Data")
 
ap_uint< 32 > cluster_size
 
ap_uint< 32 > s_udp_rx_ports
 
void gammacorrection_accel(xf::cv::Mat< XF_8UC1, 256, 256, XF_NPPC1 > &_src, xf::cv::Mat< XF_8UC1, 256, 256, XF_NPPC1 > &_dst, unsigned short Thresh, unsigned short k)
 
void markPointsOnImage(Mat &imgOutput, Mat &in_img, Mat &out_img, vector< Point > &hw_points)
Mark the points found by Gammacorrection into the image.
 
void GammacorrectionAccelArray(ap_uint< 64 > *img_inp, ap_uint< 64 > *img_out, int rows, int cols, int threshold, int k)
Top-level accelerated function of the Gammacorrection Application with array I/F.
 
bool setInputDataStream(stream< UdpAppData > &sDataStream, const string dataStreamName, const string inpFileName)
Initialize an input data stream from a file.
 
bool getOutputDataStream(stream< UdpAppData > &sDataStream, const string dataStreamName, const string outFileName)
Fill an output file with data from an output stream.
 
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.
 
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.
 
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".