cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
Gammacorrection

This is the Gammacorrection accelerated function from Vitis Vision Open Source Library. More...

Collaboration diagram for Gammacorrection:

Modules

 Gammacorrection Testbench
 This is a subgroup of Gammacorrection accelerated function with only testbench-related functions/classes/.
 
 Gammacorrection Vivado HLS
 This is a subgroup of Gammacorrection accelerated function with only synthesizable (Vivado HLS) functions/classes.
 
 Gammacorrection Host
 This is a subgroup of Gammacorrection accelerated function with only host code software.
 

Files

file  config.h
 The configuration of a Gammacorrection Example application (UDP or TCP)
 
file  gammacorrection_host.cpp
 Gammacorrection userspace application for cF (x86, ppc64).
 
file  xf_gammacorrection_config.h
 The Gammacorrection configuration header.
 
file  xf_gammacorrection_config.h
 The Gammacorrection configuration header.
 

Macros

#define CEIL(a, b)   (((a) + (b-1)) / (b))
 
#define FRAME_HEIGHT   256
 
#define FRAME_WIDTH   256
 
#define FRAME_INTERVAL   (1000/30)
 
#define PACK_SIZE   1024
 
#define BUF_LEN   65540
 
#define WRITE_OUTPUT_FILE
 
#define INPUT_TYPE_HOST   CV_8UC1
 
#define FRAME_TOTAL   FRAME_HEIGHT * FRAME_WIDTH
 
#define TOT_TRANSFERS   CEIL(FRAME_TOTAL, PACK_SIZE)
 
#define NPC1   XF_NPPC1
 
#define CH_TYPE   XF_GRAY
 
#define INPUT_PTR_WIDTH   64
 
#define OUTPUT_PTR_WIDTH   64
 
#define NPIX   XF_NPPC1
 
#define WIDTH   FRAME_WIDTH
 
#define HEIGHT   FRAME_HEIGHT
 
#define IMGSIZE   FRAME_TOTAL
 
#define IMG_PACKETS   IMGSIZE/(INPUT_PTR_WIDTH/8)
 
#define IN_TYPE   XF_8UC1
 
#define OUT_TYPE   XF_8UC1
 
#define NPC1   XF_NPPC1
 
#define CH_TYPE   XF_GRAY
 
#define INPUT_PTR_WIDTH   64
 
#define OUTPUT_PTR_WIDTH   64
 
#define NPIX   XF_NPPC1
 
#define WIDTH   FRAME_WIDTH
 
#define HEIGHT   FRAME_HEIGHT
 
#define IMGSIZE   FRAME_TOTAL
 
#define IMG_PACKETS   IMGSIZE/(INPUT_PTR_WIDTH/8)
 
#define IN_TYPE   XF_8UC1
 
#define OUT_TYPE   XF_8UC1
 

Functions

void delay (unsigned int mseconds)
 
void print_cFpZoo (void)
 
void markPointsOnImage (Mat &imgOutput, Mat &in_img, Mat &out_img, vector< Point > &hw_points)
 Mark the points found by Gammacorrection into the image. More...
 
int main (int argc, char *argv[])
 
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 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. More...
 
void GammacorrectionAccelStream (hls::stream< ap_axiu< 64, 0, 0, 0 > > &img_in_axi_stream, hls::stream< ap_axiu< 64, 0, 0, 0 > > &img_out_axi_stream, int rows, int cols, int threshold, int k)
 Top-level accelerated function of the Gammacorrection Application with array I/F. More...
 
void gammacorrection_accel (xf::cv::Mat< XF_8UC1, 256, 256, XF_NPPC1 > &imgInput1, xf::cv::Mat< XF_8UC1, 256, 256, XF_NPPC1 > &imgOutput, float gammaval)
 Top-level accelerated function of the Gammacorrection Application with xf::cv I/F. More...
 
void cornerGammacorrectionAccelArray (ap_uint< 64 > *img_inp, ap_uint< 64 > *img_out, int rows, int cols, int threshold, int k)
 
void cornerGammacorrectionAccelStream (hls::stream< ap_axiu< 64, 0, 0, 0 > > &img_in_axi_stream, hls::stream< ap_axiu< 64, 0, 0, 0 > > &img_out_axi_stream, int rows, int cols, int threshold, int k)
 

Detailed Description

This is the Gammacorrection accelerated function from Vitis Vision Open Source Library.

Macro Definition Documentation

◆ BUF_LEN

#define BUF_LEN   65540

Larger than maximum UDP packet size

Definition at line 55 of file config.h.

◆ CEIL

#define CEIL (   a,
 
)    (((a) + (b-1)) / (b))

Ceiling function without using math.h

Definition at line 37 of file config.h.

◆ CH_TYPE [1/2]

#define CH_TYPE   XF_GRAY

Definition at line 50 of file xf_gammacorrection_config.h.

◆ CH_TYPE [2/2]

#define CH_TYPE   XF_GRAY

Definition at line 50 of file xf_harris_config.h.

◆ FRAME_HEIGHT

#define FRAME_HEIGHT   256

The maximum width of frame in pixels

Definition at line 43 of file config.h.

◆ FRAME_INTERVAL

#define FRAME_INTERVAL   (1000/30)

Definition at line 48 of file config.h.

◆ FRAME_TOTAL

#define FRAME_TOTAL   FRAME_HEIGHT * FRAME_WIDTH

Definition at line 74 of file config.h.

◆ FRAME_WIDTH

#define FRAME_WIDTH   256

The maximum height of frame in pixels

Definition at line 46 of file config.h.

◆ HEIGHT [1/2]

#define HEIGHT   FRAME_HEIGHT

Definition at line 65 of file xf_gammacorrection_config.h.

◆ HEIGHT [2/2]

#define HEIGHT   FRAME_HEIGHT

Definition at line 65 of file xf_harris_config.h.

◆ IMG_PACKETS [1/2]

#define IMG_PACKETS   IMGSIZE/(INPUT_PTR_WIDTH/8)

Definition at line 69 of file xf_gammacorrection_config.h.

◆ IMG_PACKETS [2/2]

#define IMG_PACKETS   IMGSIZE/(INPUT_PTR_WIDTH/8)

Definition at line 69 of file xf_harris_config.h.

◆ IMGSIZE [1/2]

#define IMGSIZE   FRAME_TOTAL

Definition at line 67 of file xf_gammacorrection_config.h.

◆ IMGSIZE [2/2]

#define IMGSIZE   FRAME_TOTAL

Definition at line 67 of file xf_harris_config.h.

◆ IN_TYPE [1/2]

#define IN_TYPE   XF_8UC1

Definition at line 71 of file xf_gammacorrection_config.h.

◆ IN_TYPE [2/2]

#define IN_TYPE   XF_8UC1

Definition at line 71 of file xf_harris_config.h.

◆ INPUT_PTR_WIDTH [1/2]

#define INPUT_PTR_WIDTH   64

Definition at line 51 of file xf_gammacorrection_config.h.

◆ INPUT_PTR_WIDTH [2/2]

#define INPUT_PTR_WIDTH   64

Definition at line 51 of file xf_harris_config.h.

◆ INPUT_TYPE_HOST

#define INPUT_TYPE_HOST   CV_8UC1

If defined, images will be shown in pop-up windows

Definition at line 68 of file config.h.

◆ NPC1 [1/2]

#define NPC1   XF_NPPC1

Definition at line 43 of file xf_gammacorrection_config.h.

◆ NPC1 [2/2]

#define NPC1   XF_NPPC1

Definition at line 43 of file xf_harris_config.h.

◆ NPIX [1/2]

#define NPIX   XF_NPPC1

Definition at line 61 of file xf_gammacorrection_config.h.

◆ NPIX [2/2]

#define NPIX   XF_NPPC1

Definition at line 61 of file xf_harris_config.h.

◆ OUT_TYPE [1/2]

#define OUT_TYPE   XF_8UC1

Definition at line 72 of file xf_gammacorrection_config.h.

◆ OUT_TYPE [2/2]

#define OUT_TYPE   XF_8UC1

Definition at line 72 of file xf_harris_config.h.

◆ OUTPUT_PTR_WIDTH [1/2]

#define OUTPUT_PTR_WIDTH   64

Definition at line 52 of file xf_gammacorrection_config.h.

◆ OUTPUT_PTR_WIDTH [2/2]

#define OUTPUT_PTR_WIDTH   64

Definition at line 52 of file xf_harris_config.h.

◆ PACK_SIZE

#define PACK_SIZE   1024

This is our custom MTU. We must use a multiple of 8 (Bytes per transaction)! 1450 4086 udp pack size; note that OSX limits < 8100 bytes

Definition at line 52 of file config.h.

◆ TOT_TRANSFERS

#define TOT_TRANSFERS   CEIL(FRAME_TOTAL, PACK_SIZE)

The total TxRx transfers for a predefined MTU=PACK_SIZE

Definition at line 77 of file config.h.

◆ WIDTH [1/2]

#define WIDTH   FRAME_WIDTH

Definition at line 64 of file xf_gammacorrection_config.h.

◆ WIDTH [2/2]

#define WIDTH   FRAME_WIDTH

Definition at line 64 of file xf_harris_config.h.

◆ WRITE_OUTPUT_FILE

#define WRITE_OUTPUT_FILE

If defined, output images will be written

Definition at line 58 of file config.h.

Function Documentation

◆ cornerGammacorrectionAccelArray()

void cornerGammacorrectionAccelArray ( ap_uint< 64 > *  img_inp,
ap_uint< 64 > *  img_out,
int  rows,
int  cols,
int  threshold,
int  k 
)

◆ cornerGammacorrectionAccelStream()

void cornerGammacorrectionAccelStream ( hls::stream< ap_axiu< 64, 0, 0, 0 > > &  img_in_axi_stream,
hls::stream< ap_axiu< 64, 0, 0, 0 > > &  img_out_axi_stream,
int  rows,
int  cols,
int  threshold,
int  k 
)

◆ delay()

void delay ( unsigned int  mseconds)

Definition at line 47 of file gammacorrection_host.cpp.

48 {
49  clock_t goal = mseconds + clock();
50  while (goal > clock());
51 }
def clock()
Definition: common.py:174
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gammacorrection_accel() [1/2]

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 
)
Here is the caller graph for this function:

◆ gammacorrection_accel() [2/2]

void gammacorrection_accel ( xf::cv::Mat< XF_8UC1, 256, 256, XF_NPPC1 > &  imgInput1,
xf::cv::Mat< XF_8UC1, 256, 256, XF_NPPC1 > &  imgOutput,
float  gammaval 
)

Top-level accelerated function of the Gammacorrection Application with xf::cv I/F.

Returns
Nothing.

Definition at line 38 of file xf_gammacorrection_accel.cpp.

40  {
41  xf::cv::gammacorrection<IN_TYPE, OUT_TYPE, HEIGHT, WIDTH, NPC1>(imgInput1, imgOutput, gammaval);
42 }

◆ GammacorrectionAccelArray()

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.

Returns
Nothing.

Definition at line 53 of file xf_gammacorrection_accel.cpp.

54  {
55 // clang-format off
56 /* #pragma HLS INTERFACE m_axi port=img_inp offset=slave bundle=gmem1
57  #pragma HLS INTERFACE m_axi port=img_out offset=slave bundle=gmem2
58 
59  #pragma HLS INTERFACE s_axilite port=rows bundle=control
60  #pragma HLS INTERFACE s_axilite port=cols bundle=control
61  #pragma HLS INTERFACE s_axilite port=threshold bundle=control
62  #pragma HLS INTERFACE s_axilite port=k bundle=control
63  #pragma HLS INTERFACE s_axilite port=return bundle=control
64  // clang-format on
65 */
66  const int pROWS = HEIGHT;
67  const int pCOLS = WIDTH;
68  const int pNPC1 = NPIX;
69 
70  xf::cv::Mat<XF_8UC1, HEIGHT, WIDTH, NPIX> in_mat(rows, cols);
71 // clang-format off
72  #pragma HLS stream variable=in_mat.data depth=2
73  // clang-format on
74 
75  xf::cv::Mat<XF_8UC1, HEIGHT, WIDTH, NPIX> out_mat(rows, cols);
76 // clang-format off
77  #pragma HLS stream variable=out_mat.data depth=2
78 // clang-format on
79 
80 // clang-format off
81  #pragma HLS DATAFLOW
82  // clang-format on
83  xf::cv::Array2xfMat<INPUT_PTR_WIDTH, IN_TYPE, HEIGHT, WIDTH, NPIX>(img_inp, in_mat);
84  float gammaval = 0.2;
85  xf::cv::gammacorrection<IN_TYPE, OUT_TYPE, HEIGHT, WIDTH, NPC1>(in_mat, out_mat, gammaval);
86  xf::cv::xfMat2Array<OUTPUT_PTR_WIDTH, OUT_TYPE, HEIGHT, WIDTH, NPIX>(out_mat, img_out);
87 }
#define WIDTH
#define NPIX
#define HEIGHT
Here is the caller graph for this function:

◆ GammacorrectionAccelStream()

void GammacorrectionAccelStream ( hls::stream< ap_axiu< 64, 0, 0, 0 > > &  img_in_axi_stream,
hls::stream< ap_axiu< 64, 0, 0, 0 > > &  img_out_axi_stream,
int  rows,
int  cols,
int  threshold,
int  k 
)

Top-level accelerated function of the Gammacorrection Application with array I/F.

Returns
Nothing.

Definition at line 99 of file xf_gammacorrection_accel.cpp.

102  {
103  // clang-format on
104 
105  const int pROWS = HEIGHT;
106  const int pCOLS = WIDTH;
107  const int pNPC1 = NPIX;
108 
109  xf::cv::Mat<IN_TYPE, HEIGHT, WIDTH, NPIX> in_mat(rows, cols);
110  // clang-format off
111  #pragma HLS stream variable=in_mat.data depth=2
112  // clang-format on
113 
114  xf::cv::Mat<OUT_TYPE, HEIGHT, WIDTH, NPIX> out_mat(rows, cols);
115  // clang-format off
116  #pragma HLS stream variable=out_mat.data depth=2
117  // clang-format on
118 
119  // clang-format off
120  #pragma HLS DATAFLOW
121  // clang-format on
122 
123  xf::cv::axiStrm2xfMat<INPUT_PTR_WIDTH, IN_TYPE, HEIGHT, WIDTH, NPIX>(
124  img_in_axi_stream, in_mat);
125  float gammaval = 0.2;
126  xf::cv::gammacorrection<IN_TYPE, OUT_TYPE, HEIGHT, WIDTH, NPC1>(in_mat, out_mat, gammaval);
127  xf::cv::xfMat2axiStrm<OUTPUT_PTR_WIDTH, OUT_TYPE, HEIGHT, WIDTH, NPIX>(
128  out_mat, img_out_axi_stream);
129 
130 
131 }
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main testbench and user-application for Gammacorrection on host. Client

Returns
O on success, 1 on fail

Definition at line 105 of file gammacorrection_host.cpp.

105  {
106  if ((argc < 3) || (argc > 4)) { // Test for correct number of arguments
107  cerr << "Usage: " << argv[0] << " <Server> <Server Port> <optional input image>\n";
108  exit(1);
109  }
110 
111 
112  //------------------------------------------------------
113  //-- STEP-1 : Socket and variables definition
114  //------------------------------------------------------
115  string servAddress = argv[1]; // First arg: server address
116  unsigned short servPort = Socket::resolveService(argv[2], "udp");
117  char buffer[BUF_LEN]; // Buffer for echo string
118  unsigned int recvMsgSize; // Size of received message
119  unsigned int num_frame = 0;
120  float Th;
121  if (FILTER_WIDTH == 3) {
122  Th = 30532960.00;
123  } else if (FILTER_WIDTH == 5) {
124  Th = 902753878016.0;
125  } else if (FILTER_WIDTH == 7) {
126  Th = 41151168289701888.000000;
127  }
128  string out_img_file, out_points_file;
129  string out_video_file;
130  // Define the codec and create VideoWriter object.The output is stored in 'outcpp.avi' file.
131  out_video_file.assign(argv[3]);
132  out_video_file += "_fpga_img_out.avi";
133  VideoWriter video(out_video_file,CV_FOURCC('M','J','P','G'),10, Size(FRAME_WIDTH,FRAME_HEIGHT));
134 
135  print_cFpZoo();
136 
137  try {
138 
139  //------------------------------------------------------
140  //-- STEP-2 : Initialize socket connection
141  //------------------------------------------------------
142  #ifndef TB_SIM_CFP_VITIS
143  UDPSocket sock(servPort); // NOTE: It is very important to set port here in order to call
144  // bind() in the UDPSocket constructor
145  #else
146  UDPSocket sock; // NOTE: In HOST TB the port is already binded by gammacorrection_host_fwd_tb.cpp
147  #endif
148 
149  //------------------------------------------------------------------------------------
150  //-- STEP-3 : Initialize a Greyscale OpenCV Mat either from image or from video/camera
151  //------------------------------------------------------------------------------------
152  Mat frame, send, ocv_out_img;
153  vector < uchar > encoded;
154 
155  VideoCapture cap(argv[3]); // Grab the camera
156  if (!cap.isOpened()) {
157  cerr << "OpenCV Failed to open camera";
158  exit(1);
159  }
160  //frame = cv::imread(argv[3], cv::IMREAD_GRAYSCALE); // reading in the image in grey scale
161 
162  while (1) {
163  clock_t start_cycle_main = clock();
164  cap >> frame;
165  if (frame.empty()) break; // if input is an image, the loop will be executed once
166  if(frame.size().width==0) continue; //simple integrity check; skip erroneous data...
167  cout << " ___________________________________________________________________ " << endl;
168  cout << "/ \\" << endl;
169  cout << "INFO: Frame # " << ++num_frame << endl;
170  cv::cvtColor(frame,frame,CV_BGR2GRAY);
171  resize(frame, send, Size(FRAME_WIDTH, FRAME_HEIGHT), 0, 0, INTER_LINEAR);
172  cout << send.total() << endl;
173  cout << send.total() << endl;
174  if ((frame.cols != FRAME_WIDTH) || (frame.rows != FRAME_HEIGHT)) {
175  cout << "WARNING: Input frame was resized from " << frame.cols << "x"
176  << frame.rows << " to " << send.cols << "x" << send.rows << endl;
177  }
178  assert(send.total() == FRAME_WIDTH * FRAME_HEIGHT);
179 #ifdef SHOW_WINDOWS
180  namedWindow("host_send", CV_WINDOW_NORMAL);
181  imshow("host_send", send);
182 #endif
183  // Ensure that the send Mat is in continuous memory space. Typically, imread or resize
184  // will return such a continuous Mat, but we should check it.
185  assert(send.isContinuous());
186 
187  unsigned int total_pack = 1 + (send.total() * send.channels() - 1) / PACK_SIZE;
188  unsigned int total_bytes = total_pack * PACK_SIZE;
189  unsigned int bytes_in_last_pack = send.total() * send.channels() - (total_pack - 1) * PACK_SIZE;
190  assert(total_pack == TOT_TRANSFERS);
191 
192  cout << "INFO: Total packets to send/receive = " << total_pack << endl;
193  cout << "INFO: Total bytes to send/receive = " << send.total() * send.channels() << endl;
194  cout << "INFO: Total bytes in " << total_pack << " packets = " << total_bytes << endl;
195  cout << "INFO: Bytes in last packet = " << bytes_in_last_pack << endl;
196  cout << "INFO: Packet size (custom MTU) = " << PACK_SIZE << endl;
197 
198  //--------------------------------------------------------
199  //-- STEP-4 : RUN GAMMACORRECTION DETECTOR FROM OpenCV LIBRARY (SW)
200  //--------------------------------------------------------
201  clock_t start_cycle_gammacorrection_sw = clock();
202  ocv_out_img.create(send.rows, send.cols, INPUT_TYPE_HOST); // create memory for opencv output image
203  ocv_ref(send, ocv_out_img, Th);
204  clock_t end_cycle_gammacorrection_sw = clock();
205  double duration_gammacorrection_sw = (end_cycle_gammacorrection_sw - start_cycle_gammacorrection_sw) /
206  (double) CLOCKS_PER_SEC;
207  cout << "INFO: SW exec. time:" << duration_gammacorrection_sw << " seconds" << endl;
208  cout << "INFO: Effective FPS SW:" << (1 / duration_gammacorrection_sw) << " \tkbps:" <<
209  (PACK_SIZE * total_pack / duration_gammacorrection_sw / 1024 * 8) << endl;
210 
211 
212  //------------------------------------------------------
213  //-- STEP-5 : RUN GAMMACORRECTION DETECTOR FROM cF (HW)
214  //------------------------------------------------------
215  clock_t start_cycle_gammacorrection_hw = clock();
216 
217  //------------------------------------------------------
218  //-- STEP-5.1 : TX Loop
219  //------------------------------------------------------
220  clock_t last_cycle_tx = clock();
221  unsigned int sending_now = PACK_SIZE;
222  for (unsigned int i = 0; i < total_pack; i++) {
223  if ( i == total_pack - 1 ) {
224  sending_now = bytes_in_last_pack;
225  }
226  sock.sendTo( & send.data[i * PACK_SIZE], sending_now, servAddress, servPort);
227  delay(1000);
228  }
229 
230  clock_t next_cycle_tx = clock();
231  double duration_tx = (next_cycle_tx - last_cycle_tx) / (double) CLOCKS_PER_SEC;
232  cout << "INFO: Effective FPS TX:" << (1 / duration_tx) << " \tkbps:" << (PACK_SIZE *
233  total_pack / duration_tx / 1024 * 8) << endl;
234  last_cycle_tx = next_cycle_tx;
235 
236 
237  //------------------------------------------------------
238  //-- STEP-5.2 : RX Loop
239  //------------------------------------------------------
240  clock_t last_cycle_rx = clock();
241  unsigned int receiving_now = PACK_SIZE;
242  cout << "INFO: Expecting length of packs:" << total_pack << endl;
243  char * longbuf = new char[PACK_SIZE * total_pack];
244  for (unsigned int i = 0; i < total_pack; i++) {
245  if ( i == total_pack - 1 ) {
246  receiving_now = bytes_in_last_pack;
247  }
248  recvMsgSize = sock.recvFrom(buffer, BUF_LEN, servAddress, servPort);
249  if (recvMsgSize != receiving_now) {
250  cerr << "Received unexpected size pack:" << recvMsgSize << ". Expected: " <<
251  receiving_now << endl;
252  continue;
253 
254  }
255  memcpy( & longbuf[i * PACK_SIZE], buffer, receiving_now);
256  }
257 
258  cout << "INFO: Received packet from " << servAddress << ":" << servPort << endl;
259 
260  frame = cv::Mat(FRAME_HEIGHT, FRAME_WIDTH, INPUT_TYPE_HOST, longbuf); // OR vec.data() instead of ptr
261  if (frame.size().width == 0) {
262  cerr << "receive failure!" << endl;
263  continue;
264 
265  }
266 #ifdef SHOW_WINDOWS
267  namedWindow("host_recv", CV_WINDOW_NORMAL);
268  imshow("host_recv", frame);
269 #endif
270  clock_t next_cycle_rx = clock();
271  double duration_rx = (next_cycle_rx - last_cycle_rx) / (double) CLOCKS_PER_SEC;
272  cout << "INFO: Effective FPS RX:" << (1 / duration_rx) << " \tkbps:" << (PACK_SIZE *
273  total_pack / duration_rx / 1024 * 8) << endl;
274  last_cycle_rx = next_cycle_rx;
275 
276  clock_t end_cycle_gammacorrection_hw = next_cycle_rx;
277 
278  double duration_gammacorrection_hw = (end_cycle_gammacorrection_hw - start_cycle_gammacorrection_hw) /
279  (double) CLOCKS_PER_SEC;
280  cout << "INFO: HW exec. time:" << duration_gammacorrection_hw << " seconds" << endl;
281  cout << "INFO: Effective FPS HW:" << (1 / duration_gammacorrection_hw) << " \tkbps:" <<
282  (PACK_SIZE * total_pack / duration_gammacorrection_hw / 1024 * 8) << endl;
283 
284  //------------------------------------------------------
285  //-- STEP-6 : Write output files and show in windows
286  //------------------------------------------------------
287  Mat out_img;
288  out_img = send.clone();
289  vector<Point> hw_points;
290 
291  /* Mark HLS points on the image */
292  markPointsOnImage(frame, send, out_img, hw_points);
293 
294  ostringstream oss;
295  oss << "cFp_Vitis E2E:" << "INFO: Effective FPS HW:" << (1 / duration_gammacorrection_hw) <<
296  " \tkbps:" << (PACK_SIZE * total_pack / duration_gammacorrection_hw / 1024 * 8);
297  string windowName = "cFp_Vitis End2End"; //oss.str();
298  /*
299  string msg = "cFp_Vitis";
300  Scalar color(255, 0, 0);
301  int fontFace = FONT_HERSHEY_DUPLEX;
302  double fontScale = 0.5;
303  int thickness = 1;
304  putText(out_img,
305  msg, //text
306  Point(10, out_img.rows / 2), //top-left position
307  fontFace,
308  fontScale,
309  color, //font color
310  thickness);
311  */
312 #ifdef SHOW_WINDOWS
313  namedWindow(windowName, CV_WINDOW_NORMAL);
314  imshow(windowName, out_img);
315 #endif
316  //moveWindow(windowName, 0, 0);
317 #ifdef WRITE_OUTPUT_FILE
318  if (num_frame == 1) {
319  out_img_file.assign(argv[3]);
320  out_img_file += "_fpga_img_out_frame_" + to_string(num_frame) + ".png";
321  out_points_file.assign(argv[3]);
322  out_points_file += "_fpga_points_out_frame_" + to_string(num_frame) + ".png";
323  cout << "INFO: The output image file is stored at : " << out_img_file << endl;
324  cout << "INFO: The output points file is stored at : " << out_points_file << endl;
325  // We save the image received from network after being processed by Gammacorrection HW or HOST TB
326  imwrite(out_img_file, out_img);
327  imwrite(out_points_file, frame);
328  }
329  else if (num_frame > 1) {
330  // If the frame is empty, break immediately
331  if (frame.empty()) {
332  break;
333  }
334  cout << "INFO: The output video file is stored at : " << out_video_file << endl;
335  Mat tovideo;
336  if (frame.channels() != 1) {
337  tovideo = frame;
338  }
339  else {
340  cvtColor(frame, tovideo, COLOR_GRAY2BGR);
341  }
342  video.write(tovideo);
343  }
344 #endif
345  waitKey(FRAME_INTERVAL);
346  double duration_main = (clock() - start_cycle_main) / (double) CLOCKS_PER_SEC;
347  cout << "INFO: Effective FPS E2E:" << (1 / duration_main) << endl;
348  cout << "\\___________________________________________________________________/" << endl
349  << endl;
350  } // while loop
351 
352  // When everything done, release the video capture and write object
353  cap.release();
354  video.release();
355 
356  // Closes all the windows
357  destroyAllWindows();
358 
359  // Destructor closes the socket
360  } catch (SocketException & e) {
361  cerr << e.what() << endl;
362  exit(1);
363  }
364 
365  return 0;
366 }
#define FILTER_WIDTH
void ocv_ref(cv::Mat img_gray, cv::Mat &ocv_out_img, float Th)
Definition: xf_ocv_ref.hpp:552
void print_cFpZoo(void)
#define FRAME_INTERVAL
Definition: config.h:48
#define INPUT_TYPE_HOST
Definition: config.h:68
#define FRAME_HEIGHT
Definition: config.h:43
void delay(unsigned int mseconds)
void markPointsOnImage(Mat &imgOutput, Mat &in_img, Mat &out_img, vector< Point > &hw_points)
Mark the points found by Gammacorrection into the image.
#define FRAME_WIDTH
Definition: config.h:46
#define TOT_TRANSFERS
Definition: config.h:70
#define BUF_LEN
Definition: config.h:54
#define PACK_SIZE
Definition: config.h:51
def send(cFcluster cluster, node_id, data_obj, proto='udp', port=CF_DEFAULT_PORT)
Definition: comm.py:41
Here is the call graph for this function:

◆ markPointsOnImage()

void markPointsOnImage ( Mat &  imgOutput,
Mat &  in_img,
Mat &  out_img,
vector< Point > &  hw_points 
)

Mark the points found by Gammacorrection into the image.

Returns
Nothing

Definition at line 73 of file gammacorrection_host.cpp.

77 {
78 
79  for (int j = 0; j < imgOutput.rows; j++) {
80  for (int i = 0; i < (imgOutput.cols); i++) {
81  //for CV_8UC1
82  unsigned char pix = imgOutput.at<unsigned char>(j,i); //.read(j * (imgOutput.cols) + i);
83  if (pix != 0) {
84  Point tmp;
85  tmp.x = i;
86  tmp.y = j;
87  if ((tmp.x < in_img.cols) && (tmp.y < in_img.rows) && (j > 0)) {
88  hw_points.push_back(tmp);
89  }
90  short int y, x;
91  y = j;
92  x = i;
93  if (j > 0) circle(out_img, Point(x, y), 2, Scalar(0, 0, 255, 255), 1, 8, 0);
94  }
95  }
96  }
97 }
Here is the caller graph for this function:

◆ print_cFpZoo()

void print_cFpZoo ( void  )

Definition at line 53 of file gammacorrection_host.cpp.

54 {
55  cout << " " << endl;
56  cout << "...build with: " << endl;
57  cout << " ██████╗███████╗██████╗ ███████╗ ██████╗ ██████╗ " << endl;
58  cout << "██╔════╝██╔════╝██╔══██╗ ╚══███╔╝██╔═══██╗██╔═══██╗ " << endl;
59  cout << "██║ █████╗ ██████╔╝ ███╔╝ ██║ ██║██║ ██║ " << endl;
60  cout << "██║ ██╔══╝ ██╔═══╝ ███╔╝ ██║ ██║██║ ██║ " << endl;
61  cout << "╚██████╗██║ ██║███████╗███████╗╚██████╔╝╚██████╔╝ " << endl;
62  cout << " ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝ ╚═════╝ " << endl;
63  cout << "A cloudFPGA project from IBM ZRL v1.0 " << endl;
64  cout << "Quantitative Finance Monte-Carlo European Pricing Engine " << endl;
65 }
Here is the caller graph for this function: