image_interface.cpp
Go to the documentation of this file.
1 /*
2  * image_interface.c
3  *
4  * Created on: Dec 19, 2016
5  * Author: Marko Bjelonic
6  * Institute: ETH Zurich, Robotic Systems Lab
7  */
8 
10 
11 static float get_pixel(image m, int x, int y, int c) {
12  assert(x < m.w && y < m.h && c < m.c);
13  return m.data[c * m.h * m.w + y * m.w + x];
14 }
15 
16 image** load_alphabet_with_file(char* datafile) {
17  int i, j;
18  const int nsize = 8;
19  image** alphabets = (image**)calloc(nsize, sizeof(image));
20  char* labels = "/labels/%d_%d.png";
21  char* files = (char*)malloc(1 + strlen(datafile) + strlen(labels));
22  strcpy(files, datafile);
23  strcat(files, labels);
24  for (j = 0; j < nsize; ++j) {
25  alphabets[j] = (image*)calloc(128, sizeof(image));
26  for (i = 32; i < 127; ++i) {
27  char buff[256];
28  sprintf(buff, files, i, j);
29  alphabets[j][i] = load_image_color(buff, 0, 0);
30  }
31  }
32  return alphabets;
33 }
34 
35 #ifdef OPENCV
36 void generate_image(image p, cv::Mat& disp) {
37  int x, y, k;
38  if (p.c == 3) rgbgr_image(p);
39  // normalize_image(copy);
40 
41  int step = disp.step;
42  for (y = 0; y < p.h; ++y) {
43  for (x = 0; x < p.w; ++x) {
44  for (k = 0; k < p.c; ++k) {
45  disp.data[y * step + x * p.c + k] = (unsigned char)(get_pixel(p, x, y, k) * 255);
46  }
47  }
48  }
49 }
50 #endif
image ** load_alphabet_with_file(char *datafile)
static float get_pixel(image m, int x, int y, int c)
void generate_image(image p, cv::Mat &disp)


darknet_ros
Author(s): Marko Bjelonic
autogenerated on Wed May 5 2021 02:58:30