-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageInit.cpp
More file actions
72 lines (67 loc) · 1.77 KB
/
ImageInit.cpp
File metadata and controls
72 lines (67 loc) · 1.77 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "MindVision/head/CameraCapture.h"
#include <opencv2/opencv.hpp>
#include "Debug.h"
#include "./General/General.h"
#include "hikcam/hikcam_control.h"
#ifdef USING_HIKCAM
HikCam hik;
#endif // USING_HIKCAM
#ifdef USING_USB_CAMERA
cv::VideoCapture capture(0);
#endif // USING_USB_CAMERA
#ifdef VIDEO_PATH
cv::VideoCapture capture(VIDEO_PATH);
#endif // VIDEO_PATH
#ifdef TEXT_FPS
static auto timeStart = std::chrono::steady_clock::now();
#endif // TEXT_FPS
void imageInit()
{
#ifdef USING_MINDVISION
std::cout << "MindVision Init" << std::endl;
if (MVVideoCapture::Init() == -1)
{
std::cerr << "MindVision ERROR!!!" << std::endl;
return;
}
MVVideoCapture::Play();
MVVideoCapture::SetExposureTime(false, 17000);
MVVideoCapture::SetLargeResolution(false);
std::cout << "MindVision Finished!" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
#endif // USING_MINDVISION
#ifdef USING_HIKCAM
hik.initialize();
hik.printCameraInfo();
hik.startGrabbing();
#endif // USING_HIKCAM
}
void imageUpdating()
{
#ifdef USING_MINDVISION
MVVideoCapture::GetFastFrame(src);
#endif // USING_MINDVISION
#ifdef USING_HIKCAM
hik.getVideo(src);
#endif // USING_HIKCAM
#ifdef USING_USB_CAMERA
capture >> src;
#endif // USING_USB_CAMERA
#ifdef VIDEO_PATH
capture >> src;
#endif // VIDEO_PATH
}
void fpsInit()
{
#ifdef TEXT_FPS
timeStart = std::chrono::steady_clock::now();
#endif // TEXT_FPS
}
void fpsUpdating()
{
#ifdef TEXT_FPS
auto timePredict = std::chrono::steady_clock::now();
double fullMs = std::chrono::duration<double, std::milli>(timePredict - timeStart).count();
fmt::print(fmt::fg(fmt::color::gold), "FPS: {}\n", int(1000 / fullMs));
#endif // TEXT_FPS
}