image_opencv.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef IMAGE_OPENCV_H
  2. #define IMAGE_OPENCV_H
  3. #include "image.h"
  4. #include "matrix.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #ifdef OPENCV
  9. // declaration
  10. typedef void* mat_cv;
  11. typedef void* cap_cv;
  12. typedef void* write_cv;
  13. //typedef struct mat_cv mat_cv;
  14. //typedef struct cap_cv cap_cv;
  15. //typedef struct write_cv write_cv;
  16. // cv::Mat
  17. mat_cv *load_image_mat_cv(const char *filename, int flag);
  18. image load_image_cv(char *filename, int channels);
  19. image load_image_resize(char *filename, int w, int h, int c, image *im);
  20. int get_width_mat(mat_cv *mat);
  21. int get_height_mat(mat_cv *mat);
  22. void release_mat(mat_cv **mat);
  23. // IplImage - to delete
  24. //int get_width_cv(mat_cv *ipl);
  25. //int get_height_cv(mat_cv *ipl);
  26. //void release_ipl(mat_cv **ipl);
  27. // image-to-ipl, ipl-to-image, image_to_mat, mat_to_image
  28. //mat_cv *image_to_ipl(image im); // to delete
  29. //image ipl_to_image(mat_cv* src_ptr); // to delete
  30. // mat_cv *image_to_ipl(image im)
  31. // image ipl_to_image(mat_cv* src_ptr)
  32. // cv::Mat ipl_to_mat(IplImage *ipl)
  33. // IplImage *mat_to_ipl(cv::Mat mat)
  34. // Mat image_to_mat(image img)
  35. // image mat_to_image(cv::Mat mat)
  36. image mat_to_image_cv(mat_cv *mat);
  37. // Window
  38. void create_window_cv(char const* window_name, int full_screen, int width, int height);
  39. void destroy_all_windows_cv();
  40. int wait_key_cv(int delay);
  41. int wait_until_press_key_cv();
  42. void make_window(char *name, int w, int h, int fullscreen);
  43. void show_image_cv(image p, const char *name);
  44. //void show_image_cv_ipl(mat_cv *disp, const char *name);
  45. void show_image_mat(mat_cv *mat_ptr, const char *name);
  46. // Video Writer
  47. 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);
  48. void write_frame_cv(write_cv *output_video_writer, mat_cv *mat);
  49. void release_video_writer(write_cv **output_video_writer);
  50. //void *open_video_stream(const char *f, int c, int w, int h, int fps);
  51. //image get_image_from_stream(void *p);
  52. //image load_image_cv(char *filename, int channels);
  53. //int show_image_cv(image im, const char* name, int ms);
  54. // Video Capture
  55. cap_cv* get_capture_video_stream(const char *path);
  56. cap_cv* get_capture_webcam(int index);
  57. void release_capture(cap_cv* cap);
  58. mat_cv* get_capture_frame_cv(cap_cv *cap);
  59. int get_stream_fps_cpp_cv(cap_cv *cap);
  60. double get_capture_property_cv(cap_cv *cap, int property_id);
  61. double get_capture_frame_count_cv(cap_cv *cap);
  62. int set_capture_property_cv(cap_cv *cap, int property_id, double value);
  63. int set_capture_position_frame_cv(cap_cv *cap, int index);
  64. // ... Video Capture
  65. image get_image_from_stream_cpp(cap_cv *cap);
  66. image get_image_from_stream_resize(cap_cv *cap, int w, int h, int c, mat_cv** in_img, int dont_close);
  67. image get_image_from_stream_letterbox(cap_cv *cap, int w, int h, int c, mat_cv** in_img, int dont_close);
  68. // Image Saving
  69. void save_cv_png(mat_cv *img, const char *name);
  70. void save_cv_jpg(mat_cv *img, const char *name);
  71. // Draw Detection
  72. void draw_detections_cv_v3(mat_cv* show_img, detection *dets, int num, float thresh, char **names, image **alphabet, int classes, int ext_output);
  73. // Draw Loss & Accuracy chart
  74. mat_cv* draw_train_chart(char *windows_name, float max_img_loss, int max_batches, int number_of_lines, int img_size, int dont_show);
  75. void draw_train_loss(char *windows_name, mat_cv* img, int img_size, float avg_loss, float max_img_loss, int current_batch, int max_batches,
  76. float precision, int draw_precision, char *accuracy_name, int dont_show, int mjpeg_port);
  77. // Data augmentation
  78. image image_data_augmentation(mat_cv* mat, int w, int h,
  79. int pleft, int ptop, int swidth, int sheight, int flip,
  80. float dhue, float dsat, float dexp,
  81. int blur, int num_boxes, float *truth);
  82. // blend two images with (alpha and beta)
  83. void blend_images_cv(image new_img, float alpha, image old_img, float beta);
  84. // bilateralFilter bluring
  85. image blur_image(image src_img, int ksize);
  86. // Show Anchors
  87. void show_acnhors(int number_of_boxes, int num_of_clusters, float *rel_width_height_array, model anchors_data, int width, int height);
  88. void show_opencv_info();
  89. #else // OPENCV
  90. void show_opencv_info();
  91. int wait_key_cv(int delay);
  92. int wait_until_press_key_cv();
  93. void destroy_all_windows_cv();
  94. #endif // OPENCV
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif // IMAGE_OPENCV_H