interplane.Get Omega
Read in your language

ggml

[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)

Brought by drakestapleton

branch master Branches Tags History

ggml / examples / yolo / yolo-image.h

39 lines · 1346 bytes Raw Blame History
1#pragma once
2
3#include <string>
4#include <vector>
5#include <cassert>
6
7struct yolo_image {
8 int w, h, c;
9 std::vector<float> 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
34bool load_image(const char *fname, yolo_image & img);
35void draw_box_width(yolo_image & a, int x1, int y1, int x2, int y2, int w, float r, float g, float b);
36yolo_image letterbox_image(const yolo_image & im, int w, int h);
37bool save_image(const yolo_image & im, const char *name, int quality);
38yolo_image get_label(const std::vector<yolo_image> & alphabet, const std::string & label, int size);
39void draw_label(yolo_image & im, int row, int col, const yolo_image & label, const float * rgb);