|
| 1 | +#define int64 systemc_int64 |
| 2 | +#define uint64 systemc_uint64 |
| 3 | +#include <systemc.h> |
| 4 | +#undef int64 |
| 5 | +#undef uint64 |
| 6 | +#define int64 opencv_int64 |
| 7 | +#define uint64 opencv_uint64 |
| 8 | +#include <opencv2/opencv.hpp> |
| 9 | +#undef int64 |
| 10 | +#undef uint64 |
| 11 | + |
| 12 | +#include "rgb2gray_pv_model.hpp" |
| 13 | + |
| 14 | +using namespace cv; |
| 15 | + |
| 16 | +int sc_main(int, char*[]) |
| 17 | +{ |
| 18 | + Mat colorImage; |
| 19 | + |
| 20 | + unsigned char localR, localG, localB; |
| 21 | + unsigned char localResult; |
| 22 | + |
| 23 | + // Pass command linke arguments |
| 24 | + sc_argc(); |
| 25 | + sc_argv(); |
| 26 | + |
| 27 | + // Open VCD file |
| 28 | + sc_trace_file* wf = sc_create_vcd_trace_file("rgb2gray"); |
| 29 | + wf->set_time_unit(1, SC_NS); |
| 30 | + |
| 31 | + Rgb2Gray rgb2gray("rgb2gray"); |
| 32 | + |
| 33 | + colorImage = imread("../../tools/datagen/src/imgs/car.jpg", IMREAD_UNCHANGED); |
| 34 | + |
| 35 | + if (colorImage.empty()) |
| 36 | + { |
| 37 | + cout << "Image File " << "Not Found" << endl; |
| 38 | + |
| 39 | + // wait for any key press |
| 40 | + return -1; |
| 41 | + } |
| 42 | + |
| 43 | + Mat greyImage(colorImage.rows, colorImage.cols, CV_8UC1); |
| 44 | + |
| 45 | + sc_start(); |
| 46 | + |
| 47 | + for (int i = 0; i < colorImage.rows; i++) |
| 48 | + { |
| 49 | + for (int j = 0; j < colorImage.cols; j++) |
| 50 | + { |
| 51 | + localR = colorImage.at<cv::Vec3b>(i, j)[2]; |
| 52 | + localG = colorImage.at<cv::Vec3b>(i, j)[1]; |
| 53 | + localB = colorImage.at<cv::Vec3b>(i, j)[0]; |
| 54 | + rgb2gray.set_rgb_pixel(localR, localG, localB); |
| 55 | + localResult = rgb2gray.obtain_gray_value(); |
| 56 | + |
| 57 | + greyImage.at<uchar>(i, j) = localResult; |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + imshow("Window Name", colorImage); |
| 62 | + |
| 63 | + waitKey(0); |
| 64 | + |
| 65 | + imshow("Window Name", greyImage); |
| 66 | + |
| 67 | + waitKey(0); |
| 68 | + |
| 69 | + std::cout << "@" << sc_time_stamp() << " Terminating simulation" << std::endl; |
| 70 | + sc_close_vcd_trace_file(wf); |
| 71 | + |
| 72 | + return 0; |
| 73 | +} |
0 commit comments