Darknet/YOLO v3.0-177-gfa2353b
Object Detection Framework
 
Loading...
Searching...
No Matches
DarknetImage Struct Reference

The structure DarknetImage is used to store a normalized RGB Darknet image. More...

#include "darknet.h"

Collaboration diagram for DarknetImage:

Public Attributes

int c
 channel
 
float * data
 normalized floats, the number of which is determined by "w * h * c"
 
int h
 height
 
int w
 width
 

Detailed Description

The structure DarknetImage is used to store a normalized RGB Darknet image.

The format is intended to be used for internal use by Darknet, but there are some situations where it may also be used or referenced externally via the Darknet API.

Moving forward starting with Darknet V3 (August 2024), where possible the emphasis will be to use OpenCV cv::Mat objects in the external-facing API instead of DarknetImage. Internally, Darknet will continue to use Image.

Warning
Keep this structure as POD (plain-old-data) since there are many places in the old code where memory for these image objects is calloc'd. This structure was originally part of the old Darknet C API, which is why it exists this way and not as a C++ class with methods.

Within data, the image is stored as 3 non-interlaced channels in RGB order. Each channel is stored as rows, from top to bottom. So a 5x3 RGB image would look like this:

r r r r r
r r r r r
r r r r r
g g g g g
g g g g g
g g g g g
b b b b b
b b b b b
b b b b b

A 5x3 pure red image, with a blueish/green square in the bottom-right corner would look like this:

1.0 1.0 1.0 1.0 1.0 // red channel
1.0 1.0 1.0 0.0 0.0 // note the lack of red in the bottom-right corner
1.0 1.0 1.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 // green channel
0.0 0.0 0.0 0.5 0.5
0.0 0.0 0.0 0.5 0.5
0.0 0.0 0.0 0.0 0.0 // blue channel
0.0 0.0 0.0 1.0 1.0 // note the blue square in the bottom-right corner
0.0 0.0 0.0 1.0 1.0

For additional information or to help debug the internals of DarknetImage, see Darknet::image_as_debug_string().

See also
Darknet::load_image()
Darknet::copy_image()
make_empty_image()
make_image()
Darknet::free_image()

Member Data Documentation

◆ c

int DarknetImage::c

channel

◆ data

float* DarknetImage::data

normalized floats, the number of which is determined by "w * h * c"

◆ h

int DarknetImage::h

height

◆ w

int DarknetImage::w

width


The documentation for this struct was generated from the following file: