Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/examples/yolo/yolo-image.h # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / examples / yolo / yolo-image.h` 39 lines ยท 1346 bytes Raw Blame History 1 #pragma once 2 3 #include 4 #include 5 #include 6 7 struct yolo_image { 8 int w, h, c; 9 std::vector data; 10 11 yolo_image() : w(0), h(0), c(0) {} 12 yolo_image(int w, int h, int c) : w(w), h(h), c(c), data(w*h*c) {} 13 14 float get_pixel(int x, int y, int c) const { 15 assert(x >= 0 && x < w && y >= 0 && y < h && c >= 0 && c < this->c); 16 return data[c*w*h + y*w + x]; 17 } 18 19 void set_pixel(int x, int y, int c, float val) { 20 assert(x >= 0 && x < w && y >= 0 && y < h && c >= 0 && c < this->c); 21 data[c*w*h + y*w + x] = val; 22 } 23 24 void add_pixel(int x, int y, int c, float val) { 25 assert(x >= 0 && x < w && y >= 0 && y < h && c >= 0 && c < this->c); 26 data[c*w*h + y*w + x] += val; 27 } 28 29 void fill(float val) { 30 std::fill(data.begin(), data.end(), val); 31 } 32 }; 33 34 bool load_image(const char *fname, yolo_image & img); 35 void draw_box_width(yolo_image & a, int x1, int y1, int x2, int y2, int w, float r, float g, float b); 36 yolo_image letterbox_image(const yolo_image & im, int w, int h); 37 bool save_image(const yolo_image & im, const char *name, int quality); 38 yolo_image get_label(const std::vector & alphabet, const std::string & label, int size); 39 void draw_label(yolo_image & im, int row, int col, const yolo_image & label, const float * rgb);