Darknet/YOLO
Object Detection Framework
image_opencv.h File Reference
Include dependency graph for image_opencv.h:
This graph shows which files directly or indirectly include this file:

Typedefs

typedef void * mat_cv
 Hide a C++ cv::Mat object as a C style void* pointer. More...
 
typedef void * cap_cv
 Hide a C++ cv::VideoCapture object as a C style void* pointer. More...
 
typedef void * write_cv
 Hide a C++ cv::VideoWriter object as a C style void* pointer. More...
 

Functions

mat_cvload_image_mat_cv (const char *const filename, int flag)
 Load the given image using OpenCV and return it as a "C" style mat_cv void* pointer. More...
 
image load_image_cv (char *filename, int channels)
 Similar to load_image_mat_cv() but is explicit about the image channels and returns a Darknet-style image. More...
 
image load_image_resize (char *filename, int w, int h, int c, image *im)
 Load the given image, but then immediately resize it to the desired dimensions. More...
 
int get_width_mat (mat_cv *mat)
 
int get_height_mat (mat_cv *mat)
 
void release_mat (mat_cv **mat)
 Frees the cv::Mat object allocated in load_image_mat_cv(). More...
 
image mat_to_image_cv (mat_cv *mat)
 
void create_window_cv (char const *window_name, int full_screen, int width, int height)
 
void resize_window_cv (char const *window_name, int width, int height)
 
void move_window_cv (char const *window_name, int x, int y)
 
void destroy_all_windows_cv ()
 
int wait_key_cv (int delay)
 
int wait_until_press_key_cv ()
 
void show_image_cv (image p, const char *name)
 
void show_image_mat (mat_cv *mat_ptr, const char *name)
 
write_cvcreate_video_writer (char *out_filename, char c1, char c2, char c3, char c4, int fps, int width, int height, int is_color)
 
void write_frame_cv (write_cv *output_video_writer, mat_cv *mat)
 
void release_video_writer (write_cv **output_video_writer)
 
cap_cvget_capture_video_stream (const char *path)
 
cap_cvget_capture_webcam (int index)
 
void release_capture (cap_cv *cap)
 
mat_cvget_capture_frame_cv (cap_cv *cap)
 
int get_stream_fps_cpp_cv (cap_cv *cap)
 
double get_capture_property_cv (cap_cv *cap, int property_id)
 
double get_capture_frame_count_cv (cap_cv *cap)
 
int set_capture_property_cv (cap_cv *cap, int property_id, double value)
 
int set_capture_position_frame_cv (cap_cv *cap, int index)
 
image get_image_from_stream_cpp (cap_cv *cap)
 
image get_image_from_stream_resize (cap_cv *cap, int w, int h, int c, mat_cv **in_img, int dont_close)
 
image get_image_from_stream_letterbox (cap_cv *cap, int w, int h, int c, mat_cv **in_img, int dont_close)
 
void consume_frame (cap_cv *cap)
 
void save_cv_png (mat_cv *img, const char *name)
 
void save_cv_jpg (mat_cv *img, const char *name)
 
void draw_detections_cv_v3 (mat_cv *show_img, detection *dets, int num, float thresh, char **names, image **alphabet, int classes, int ext_output)
 
mat_cvdraw_initial_train_chart (char *windows_name, float max_img_loss, int max_batches, int number_of_lines, int img_size, int dont_show, char *chart_path)
 Draw the intial Loss & Accuracy chart. This is called once at the very start. More...
 
void update_train_loss_chart (char *windows_name, mat_cv *img, int img_size, float avg_loss, float max_img_loss, int current_batch, int max_batches, float precision, int draw_precision, char *accuracy_name, float contr_acc, int dont_show, int mjpeg_port, double time_remaining)
 Update the Loss & Accuracy chart with the given information. This is called repeatedly as more data is produced during training. More...
 
image image_data_augmentation (mat_cv *mat, int w, int h, int pleft, int ptop, int swidth, int sheight, int flip, float dhue, float dsat, float dexp, int gaussian_noise, int blur, int num_boxes, int truth_size, float *truth)
 
void blend_images_cv (image new_img, float alpha, image old_img, float beta)
 
image blur_image (image src_img, int ksize)
 
void cv_draw_object (image sized, float *truth_cpu, int max_boxes, int num_truth, int *it_num_set, float *lr_set, int *boxonly, int classes, char **names)
 
void show_acnhors (int number_of_boxes, int num_of_clusters, float *rel_width_height_array, model anchors_data, int width, int height)
 
void show_opencv_info ()
 

Typedef Documentation

◆ mat_cv

typedef void* mat_cv

Hide a C++ cv::Mat object as a C style void* pointer.

◆ cap_cv

typedef void* cap_cv

Hide a C++ cv::VideoCapture object as a C style void* pointer.

◆ write_cv

typedef void* write_cv

Hide a C++ cv::VideoWriter object as a C style void* pointer.

Function Documentation

◆ load_image_mat_cv()

mat_cv* load_image_mat_cv ( const char *const  filename,
int  flag 
)

Load the given image using OpenCV and return it as a "C" style mat_cv void* pointer.

Converts the image from the usual OpenCV BGR format to RGB. Remember to free the image with release_mat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_image_cv()

image load_image_cv ( char *  filename,
int  channels 
)

Similar to load_image_mat_cv() but is explicit about the image channels and returns a Darknet-style image.

Channels should be 0 (colour), 1 (grayscale) or 3 (colour). This uses load_image_mat_cv() so the channels will be converted fro BGR to RGB.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_image_resize()

image load_image_resize ( char *  filename,
int  w,
int  h,
int  c,
image im 
)

Load the given image, but then immediately resize it to the desired dimensions.

Does not maintain apect ratio, and does not use letterbox.

Here is the call graph for this function:

◆ get_width_mat()

int get_width_mat ( mat_cv mat)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_height_mat()

int get_height_mat ( mat_cv mat)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ release_mat()

void release_mat ( mat_cv **  mat)

Frees the cv::Mat object allocated in load_image_mat_cv().

Here is the caller graph for this function:

◆ mat_to_image_cv()

image mat_to_image_cv ( mat_cv mat)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_window_cv()

void create_window_cv ( char const *  window_name,
int  full_screen,
int  width,
int  height 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize_window_cv()

void resize_window_cv ( char const *  window_name,
int  width,
int  height 
)
Here is the caller graph for this function:

◆ move_window_cv()

void move_window_cv ( char const *  window_name,
int  x,
int  y 
)

◆ destroy_all_windows_cv()

void destroy_all_windows_cv ( )
Here is the caller graph for this function:

◆ wait_key_cv()

int wait_key_cv ( int  delay)
Here is the caller graph for this function:

◆ wait_until_press_key_cv()

int wait_until_press_key_cv ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_image_cv()

void show_image_cv ( image  p,
const char *  name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_image_mat()

void show_image_mat ( mat_cv mat_ptr,
const char *  name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_video_writer()

write_cv* create_video_writer ( char *  out_filename,
char  c1,
char  c2,
char  c3,
char  c4,
int  fps,
int  width,
int  height,
int  is_color 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_frame_cv()

void write_frame_cv ( write_cv output_video_writer,
mat_cv mat 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ release_video_writer()

void release_video_writer ( write_cv **  output_video_writer)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_capture_video_stream()

cap_cv* get_capture_video_stream ( const char *  path)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_capture_webcam()

cap_cv* get_capture_webcam ( int  index)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ release_capture()

void release_capture ( cap_cv cap)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_capture_frame_cv()

mat_cv* get_capture_frame_cv ( cap_cv cap)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_stream_fps_cpp_cv()

int get_stream_fps_cpp_cv ( cap_cv cap)
Todo:
why is this returning an int?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_capture_property_cv()

double get_capture_property_cv ( cap_cv cap,
int  property_id 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_capture_frame_count_cv()

double get_capture_frame_count_cv ( cap_cv cap)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_capture_property_cv()

int set_capture_property_cv ( cap_cv cap,
int  property_id,
double  value 
)
Todo:
why does this return int?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_capture_position_frame_cv()

int set_capture_position_frame_cv ( cap_cv cap,
int  index 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_image_from_stream_cpp()

image get_image_from_stream_cpp ( cap_cv cap)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_image_from_stream_resize()

image get_image_from_stream_resize ( cap_cv cap,
int  w,
int  h,
int  c,
mat_cv **  in_img,
int  dont_close 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_image_from_stream_letterbox()

image get_image_from_stream_letterbox ( cap_cv cap,
int  w,
int  h,
int  c,
mat_cv **  in_img,
int  dont_close 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ consume_frame()

void consume_frame ( cap_cv cap)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_cv_png()

void save_cv_png ( mat_cv img,
const char *  name 
)
Here is the call graph for this function:

◆ save_cv_jpg()

void save_cv_jpg ( mat_cv img,
const char *  name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw_detections_cv_v3()

void draw_detections_cv_v3 ( mat_cv show_img,
detection dets,
int  num,
float  thresh,
char **  names,
image **  alphabet,
int  classes,
int  ext_output 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw_initial_train_chart()

mat_cv* draw_initial_train_chart ( char *  windows_name,
float  max_img_loss,
int  max_batches,
int  number_of_lines,
int  img_size,
int  dont_show,
char *  chart_path 
)

Draw the intial Loss & Accuracy chart. This is called once at the very start.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_train_loss_chart()

void update_train_loss_chart ( char *  windows_name,
mat_cv img,
int  img_size,
float  avg_loss,
float  max_img_loss,
int  current_batch,
int  max_batches,
float  precision,
int  draw_precision,
char *  accuracy_name,
float  contr_acc,
int  dont_show,
int  mjpeg_port,
double  time_remaining 
)

Update the Loss & Accuracy chart with the given information. This is called repeatedly as more data is produced during training.

Note
This is called at every iteration to update the chart, but the output file isn't saved to disk every time.
In some parts of the code, this is called at the end of the iteration, once the batch number (iteration) has already been updated. So the very first time through, the "current_batch" is already set to 1, not 0. In othe parts, this is called at the start of the iteration, so the first time through the "current_batch" is zero.
Todo:
why is this not done above in draw_initial_train_chart()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ image_data_augmentation()

image image_data_augmentation ( mat_cv mat,
int  w,
int  h,
int  pleft,
int  ptop,
int  swidth,
int  sheight,
int  flip,
float  dhue,
float  dsat,
float  dexp,
int  gaussian_noise,
int  blur,
int  num_boxes,
int  truth_size,
float *  truth 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ blend_images_cv()

void blend_images_cv ( image  new_img,
float  alpha,
image  old_img,
float  beta 
)
Here is the caller graph for this function:

◆ blur_image()

image blur_image ( image  src_img,
int  ksize 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cv_draw_object()

void cv_draw_object ( image  sized,
float *  truth_cpu,
int  max_boxes,
int  num_truth,
int *  it_num_set,
float *  lr_set,
int *  boxonly,
int  classes,
char **  names 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_acnhors()

void show_acnhors ( int  number_of_boxes,
int  num_of_clusters,
float *  rel_width_height_array,
model  anchors_data,
int  width,
int  height 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_opencv_info()

void show_opencv_info ( )
Here is the caller graph for this function: