| 194 | |
| 195 | |
| 196 | int loadNormalizedInputDatatoBuffptr(const char *img_path, IO_DATA_TYPE *buff_ptr, float* mean_ptr, float* var_ptr, int height, int width, int img_channel, |
| 197 | int resize_h, int resize_w, int inp_bw, int fbits_input)//, int normalize_enable) |
| 198 | { |
| 199 | |
| 200 | cv::Mat frame; |
| 201 | |
| 202 | frame = imread(img_path, 1); |
| 203 | //frame = imread("/proj/sdxapps/refdes/ML_SoftwareTeam/Ristretto/ResNet-50-Tf_Q_5_11_test/input/camel.jpg", 1); |
| 204 | if(!frame.data) |
| 205 | { |
| 206 | std :: cout << "[ERROR] Image read failed - " << img_path << std :: endl; |
| 207 | return -1; |
| 208 | } |
| 209 | else |
| 210 | { |
| 211 | std :: cout << "[IMRDx] Image read : " << img_path << std :: endl; |
| 212 | } |
| 213 | |
| 214 | int h_off = 0; |
| 215 | int w_off = 0; |
| 216 | |
| 217 | cv::Mat cv_img[1], cv_cropped_img[1]; |
| 218 | |
| 219 | if((resize_h != frame.rows) || (resize_w != frame.cols)) |
| 220 | { |
| 221 | cv::resize(frame, cv_img[0], cv::Size(resize_w, resize_h)); |
| 222 | |
| 223 | if(resize_h > height) |
| 224 | { |
| 225 | h_off = (resize_h - height) / 2; |
| 226 | w_off = (resize_w - width) / 2; |
| 227 | cv::Rect roi(w_off, h_off, width, height); |
| 228 | cv_cropped_img[0] = cv_img[0](roi); |
| 229 | } |
| 230 | else |
| 231 | cv_cropped_img[0] = cv_img[0]; |
| 232 | } |
| 233 | else |
| 234 | { |
| 235 | frame.copyTo(cv_cropped_img[0]); |
| 236 | } |
| 237 | |
| 238 | #if DEBUG |
| 239 | char path1[100]; |
| 240 | sprintf(path1, "data_out.txt"); |
| 241 | |
| 242 | FILE* fp_img = fopen(path1, "r"); |
| 243 | |
| 244 | if(fp_img == NULL) |
| 245 | { |
| 246 | fprintf(stderr, "\n** Cannot open mean file (or) No mean file : %s **\n", path1); |
| 247 | //return NULL; |
| 248 | } |
| 249 | |
| 250 | int size_of_input = height*width*img_channel; |
| 251 | float *in_buf = (float *)malloc(size_of_input*sizeof(float)); |
| 252 | |
| 253 | float float_val1; |
no test coverage detected