forked from madhawav/YOLO3-4-Py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbridge.cpp
45 lines (30 loc) · 776 Bytes
/
bridge.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "bridge.h"
#if USE_CV == 1
#include <iostream>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
// Include darknet as a C Library
image ipl_to_image(IplImage* src);
#ifdef __cplusplus
}
#endif
using namespace cv;
image get_darknet_image(const Mat &input){
// Darknet requires RGB order. Convert BGR to RGB.
Mat flipped;
cvtColor(input, flipped, CV_RGB2BGR);
// Darknet uses IPL Image
IplImage* iplImage;
iplImage = cvCreateImage(cvSize(flipped.cols,flipped.rows),8,3);
IplImage ipltemp=flipped;
cvCopy(&ipltemp,iplImage);
flipped.release();
// Convert to Darknet Image
image darknet_image = ipl_to_image(iplImage);
// Free memory
cvReleaseImage(&iplImage);
return darknet_image;
}
#endif