-
Notifications
You must be signed in to change notification settings - Fork 4
/
ocvframe.h
87 lines (67 loc) · 2.35 KB
/
ocvframe.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
///////////////////////////////////////////////////////////////////////////////
// Name: ocvframe.h
// Purpose: Gets and displays images coming from various OpenCV sources
// Author: PB
// Created: 2020-09-16
// Copyright: (c) 2020 PB
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef OCVFRAME_H
#define OCVFRAME_H
#include <wx/wx.h>
// forward declarations
class WXDLLIMPEXP_FWD_CORE wxSlider;
class wxBitmapFromOpenCVPanel;
namespace cv
{
class Mat;
class VideoCapture;
}
class CameraThread;
// This class can open an OpenCV source of images (image file, video file,
// default WebCam, and IP camera) and display the images using wxBitmapFromOpenCVPanel.
class OpenCVFrame : public wxFrame
{
public:
OpenCVFrame();
~OpenCVFrame();
private:
enum Mode
{
Empty,
Image,
Video,
WebCam,
IPCamera,
};
Mode m_mode{Empty};
wxString m_sourceName;
int m_currentVideoFrameNumber{0};
cv::VideoCapture* m_videoCapture{nullptr};
CameraThread* m_cameraThread{nullptr};
wxBitmapFromOpenCVPanel* m_bitmapPanel;
wxSlider* m_videoSlider;
wxButton* m_propertiesButton;
static wxBitmap ConvertMatToBitmap(const cv::Mat& matBitmap, long& timeConvert);
void Clear();
void UpdateFrameTitle();
void ShowVideoFrame(int frameNumber);
// If address is empty, the default webcam is used.
// resolution and useMJPEG are used only for webcam.
bool StartCameraCapture(const wxString& address,
const wxSize& resolution = wxSize(),
bool useMJPEG = false);
bool StartCameraThread();
void DeleteCameraThread();
void OnImage(wxCommandEvent&);
void OnVideo(wxCommandEvent&);
void OnWebCam(wxCommandEvent&);
void OnIPCamera(wxCommandEvent&);
void OnClear(wxCommandEvent&);
void OnProperties(wxCommandEvent&);
void OnVideoSetFrame(wxCommandEvent& evt);
void OnCameraFrame(wxThreadEvent& evt);
void OnCameraEmpty(wxThreadEvent&);
void OnCameraException(wxThreadEvent& evt);
};
#endif // #ifndef OCVFRAME_H