Main testbench and user-application for Gammacorrection on host. Client 
  106     if ((argc < 3) || (argc > 4)) { 
 
  107         cerr << 
"Usage: " << argv[0] << 
" <Server> <Server Port> <optional input image>\n";
 
  115     string servAddress = argv[1]; 
 
  116     unsigned short servPort = Socket::resolveService(argv[2], 
"udp");
 
  118     unsigned int recvMsgSize; 
 
  126         Th = 41151168289701888.000000;
 
  128     string out_img_file, out_points_file;
 
  129     string out_video_file;
 
  131     out_video_file.assign(argv[3]);
 
  132     out_video_file += 
"_fpga_img_out.avi";
 
  142         #ifndef TB_SIM_CFP_VITIS 
  143         UDPSocket sock(servPort); 
 
  153         vector < uchar > encoded;
 
  155         VideoCapture 
cap(argv[3]); 
 
  156         if (!
cap.isOpened()) {
 
  157             cerr << 
"OpenCV Failed to open camera";
 
  163             clock_t start_cycle_main = 
clock();
 
  165             if (
frame.empty()) 
break; 
 
  166             if(
frame.size().width==0) 
continue; 
 
  167             cout << 
" ___________________________________________________________________ " << endl;
 
  168             cout << 
"/                                                                   \\" << endl;
 
  169         cout << 
"INFO: Frame # " << ++
num_frame << endl;
 
  172         cout << 
send.total() << endl;
 
  173         cout << 
send.total() << endl;
 
  175             cout << 
"WARNING: Input frame was resized from " << 
frame.cols << 
"x"  
  176         << 
frame.rows << 
" to " << 
send.cols << 
"x" << 
send.rows << endl;
 
  180         namedWindow(
"host_send", CV_WINDOW_NORMAL);
 
  181             imshow(
"host_send", 
send);
 
  185         assert(
send.isContinuous());
 
  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;
 
  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;
 
  201             clock_t start_cycle_gammacorrection_sw = 
clock();
 
  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;
 
  215             clock_t start_cycle_gammacorrection_hw = 
clock();
 
  220             clock_t last_cycle_tx = 
clock();
 
  222             for (
unsigned int i = 0; i < total_pack; i++) {
 
  223                 if ( i == total_pack - 1 ) {
 
  224                     sending_now = bytes_in_last_pack;
 
  226         sock.sendTo( & 
send.data[i * 
PACK_SIZE], sending_now, servAddress, servPort);
 
  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;
 
  240         clock_t last_cycle_rx = 
clock();
 
  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;
 
  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;
 
  255                 memcpy( & longbuf[i * 
PACK_SIZE], buffer, receiving_now);
 
  258             cout << 
"INFO: Received packet from " << servAddress << 
":" << servPort << endl;
 
  261         if (
frame.size().width == 0) {
 
  262                 cerr << 
"receive failure!" << endl;
 
  267             namedWindow(
"host_recv", CV_WINDOW_NORMAL);
 
  268             imshow(
"host_recv", 
frame);
 
  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;
 
  276         clock_t end_cycle_gammacorrection_hw = next_cycle_rx;
 
  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;      
 
  288             out_img = 
send.clone();
 
  289             vector<Point> hw_points;
 
  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"; 
 
  313         namedWindow(windowName, CV_WINDOW_NORMAL);
 
  314         imshow(windowName, out_img);
 
  317 #ifdef WRITE_OUTPUT_FILE 
  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; 
 
  326           imwrite(out_img_file, out_img);
 
  327           imwrite(out_points_file, 
frame);
 
  334           cout << 
"INFO: The output video file is stored at  : " << out_video_file << endl;
 
  336           if (
frame.channels() != 1) {
 
  340         cvtColor(
frame, tovideo, COLOR_GRAY2BGR);
 
  342           video.write(tovideo);
 
  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
 
  360     } 
catch (SocketException & e) {
 
  361         cerr << e.what() << endl;
 
void ocv_ref(cv::Mat img_gray, cv::Mat &ocv_out_img, float Th)
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.
def send(cFcluster cluster, node_id, data_obj, proto='udp', port=CF_DEFAULT_PORT)