cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
common.hpp
Go to the documentation of this file.
1 
17 #ifndef _TEST_COMMON_H_
18 #define _TEST_COMMON_H_
19 
20 
21 #include <stdio.h>
22 #include <string>
23 #include <hls_stream.h>
24 #ifdef ROLE_IS_HARRIS
25 #include "../../harris/include/harris.hpp"
26 #endif
27 #ifdef ROLE_IS_MEDIANBLUR
28 #include "../../median_blur/include/median_blur.hpp"
29 #endif
30 #ifdef ROLE_IS_WARPTRANSFORM
31 #include "../../warp_transform/include/warp_transform.hpp"
32 #endif
33 
34 #include "common/xf_headers.hpp"
35 
36 #ifdef ROLE_IS_HARRIS
37 #include "../../harris/include/xf_harris_config.h"
38 #include "../../harris/include/xf_ocv_ref.hpp"
39 #endif
40 #ifdef ROLE_IS_MEDIANBLUR
41 #include "../../median_blur/include/xf_median_blur_config.h"
42 #include "../../median_blur/include/xf_ocv_ref.hpp"
43 #endif
44 #ifdef ROLE_IS_WARPTRANSFORM
45 #include "../../warp_transform/include/xf_warp_transform_config.h"
46 #include "../../warp_transform/include/xf_ocv_ref.hpp"
47 #endif
48 
49 
50 
51 //---------------------------------------------------------
52 // HELPERS FOR THE DEBUGGING TRACES
53 // .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)
54 //---------------------------------------------------------
55 #define THIS_NAME "TB"
56 
57 #define TRACE_OFF 0x0000
58 #define TRACE_URIF 1 << 1
59 #define TRACE_UAF 1 << 2
60 #define TRACE_MMIO 1 << 3
61 #define TRACE_ALL 0xFFFF
62 
63 #define DEBUG_LEVEL (TRACE_ALL)
64 
65 
66 //------------------------------------------------------
67 //-- TESTBENCH DEFINES
68 //------------------------------------------------------
69 #define OK true
70 #define KO false
71 #define VALID true
72 #define UNVALID false
73 #define DEBUG_TRACE true
74 
75 #define ENABLED (ap_uint<1>)1
76 #define DISABLED (ap_uint<1>)0
77 
78 
79 
80 
81 
89 bool setInputDataStream(stream<UdpWord> &sDataStream, const std::string dataStreamName,
90  const std::string inpFileName, int simCnt);
91 
92 
93 
100 bool setInputFileToArray(const std::string inpFileName, ap_uint<OUTPUT_PTR_WIDTH>* imgArray, int simCnt);
101 
102 
103 
112 bool readDataStream(stream <UdpWord> &sDataStream, UdpWord *udpWord);
113 
114 
115 
121 ap_uint<64> pack_ap_uint_64_ (ap_uint<8> *buffer);
122 
123 
124 
131 bool dumpDataToFile(UdpWord *udpWord, std::ofstream &outFileStream);
132 
133 
134 
142 bool getOutputDataStream(stream<UdpWord> &sDataStream,
143  const std::string dataStreamName, const std::string outFileName, int simCnt);
144 
145 
146 
153 bool dumpImgToFile(xf::cv::Mat<OUT_TYPE, HEIGHT, WIDTH, NPIX>& _img,
154  const std::string outFileName, int simCnt);
155 
156 
157 
162 unsigned int writeCornersIntoFile(cv::Mat& in_img, cv::Mat& ocv_out_img, cv::Mat& out_img,
163  std::vector<cv::Point>& hls_points,
164  std::vector<cv::Point>& ocv_points,
165  std::vector<cv::Point>& common_pts);
166 
167 
168 
173 void markPointsOnImage(xf::cv::Mat<OUT_TYPE, HEIGHT, WIDTH, NPIX>& imgOutput, cv::Mat& in_img,
174  cv::Mat& out_img, std::vector<cv::Point>& hls_points);
175 
176 
177 #endif
178 
int simCnt
Definition: tb_fmc.cpp:113
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 setInputDataStream(stream< UdpWord > &sDataStream, const std::string dataStreamName, const std::string inpFileName, int simCnt)
Initialize an input data stream from a file.
bool readDataStream(stream< UdpWord > &sDataStream, UdpWord *udpWord)
Read data from a stream.
Definition: common.cpp:103
bool dumpDataToFile(UdpWord *udpWord, std::ofstream &outFileStream)
Dump a data word to a file.
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.
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.
Definition: common.cpp:437
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.
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.
Definition: common.cpp:506
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".