Skip to content

Commit 31ce149

Browse files
committed
Major update
Webcam in progress
1 parent fbd5aad commit 31ce149

File tree

9 files changed

+1517
-200
lines changed

9 files changed

+1517
-200
lines changed

CommandCam.cpp

Lines changed: 548 additions & 0 deletions
Large diffs are not rendered by default.

include/Kamera.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef KAMERA_HPP
2+
#define KAMERA_HPP
3+
4+
#include "wx/wx.h"
5+
#include <windows.h>
6+
#include <dshow.h>
7+
#include <strmif.h>
8+
#include <d3d9.h>
9+
#include <Vmr9.h>
10+
#include <vector>
11+
#include <assert.h>
12+
#pragma comment(lib, "strmiids")
13+
14+
class Kamera
15+
{
16+
public:
17+
Kamera();
18+
void Obrazek(wxImage *img);
19+
private:
20+
//Moje fce
21+
HRESULT EnumerateDevices(REFGUID category, IEnumMoniker **ppEnum);
22+
void NastavKamery();
23+
24+
//moje promenny
25+
int stav;
26+
//IBaseFilter *camera_filter;
27+
IBaseFilter *camera_filter;
28+
29+
};
30+
31+
#endif

main.hpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
3+
#include "wx/wxprec.h"
4+
5+
#ifdef __BORLANDC__
6+
#pragma hdrstop
7+
#endif
8+
9+
// for all others, include the necessary headers (this file is usually all you
10+
// need because it includes almost all "standard" wxWidgets headers)
11+
#ifndef WX_PRECOMP
12+
#include "wx/wx.h"
13+
#endif
14+
15+
// ----------------------------------------------------------------------------
16+
// resources
17+
// ----------------------------------------------------------------------------
18+
19+
// the application icon (under Windows and OS/2 it is in resources and even
20+
// though we could still include the XPM here it would be unused)
21+
#ifndef wxHAS_IMAGES_IN_RESOURCES
22+
#include "../sample.xpm"
23+
#endif
24+
25+
#include "wx/image.h"
26+
#include "wx/file.h"
27+
#include "wx/filename.h"
28+
#include "wx/graphics.h"
29+
#include "wx/mstream.h"
30+
#include "wx/wfstream.h"
31+
#include "wx/quantize.h"
32+
#include "wx/scopedptr.h"
33+
#include "wx/stopwatch.h"
34+
#include "wx/versioninfo.h"
35+
#include "wx/dcbuffer.h"
36+
37+
#if wxUSE_CLIPBOARD
38+
#include "wx/dataobj.h"
39+
#include "wx/clipbrd.h"
40+
#endif // wxUSE_CLIPBOARD
41+
42+
#if defined(__WXMSW__)
43+
#ifdef wxHAVE_RAW_BITMAP
44+
#include "wx/rawbmp.h"
45+
#endif
46+
#endif
47+
48+
#if defined(__WXMAC__) || defined(__WXGTK__)
49+
#define wxHAVE_RAW_BITMAP
50+
#include "wx/rawbmp.h"
51+
#endif
52+
53+
#include "include/Kamera.hpp"

minimal.cpp

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
2+
#include "main.hpp"
3+
4+
5+
enum
6+
{
7+
// menu items
8+
BUTTON_Quit = wxID_EXIT,
9+
10+
// it is important for the id corresponding to the "About" command to have
11+
// this standard value as otherwise it won't be handled properly under Mac
12+
// (where it is special and put into the "Apple" menu)
13+
};
14+
15+
16+
17+
class AppMain : public wxApp
18+
{
19+
public:
20+
// override base class virtuals
21+
// ----------------------------
22+
23+
// this one is called on application startup and is a good place for the app
24+
// initialization (doing it here and not in the ctor allows to have an error
25+
// return: if OnInit() returns false, the application terminates)
26+
virtual bool OnInit();
27+
private:
28+
Kamera *kamera;
29+
};
30+
31+
32+
class FrameMain : public wxFrame
33+
{
34+
public:
35+
// ctor(s)
36+
FrameMain(const wxString& title);
37+
38+
// event handlers (these functions should _not_ be virtual)
39+
void OnQuit(wxCommandEvent& event);
40+
void OnPaint(wxPaintEvent& event);
41+
42+
private:
43+
// any class wishing to process wxWidgets events must use this macro
44+
wxButton *QuitBut;
45+
void DrawImage(wxDC &dc);
46+
Kamera *kamera;
47+
DECLARE_EVENT_TABLE()
48+
};
49+
50+
51+
BEGIN_EVENT_TABLE(FrameMain, wxFrame)
52+
EVT_BUTTON(BUTTON_Quit, FrameMain::OnQuit)
53+
EVT_PAINT(FrameMain::OnPaint)
54+
END_EVENT_TABLE()
55+
56+
57+
IMPLEMENT_APP(AppMain)
58+
59+
60+
61+
62+
// frame constructor
63+
FrameMain::FrameMain(const wxString& title)
64+
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(640,480), 0)
65+
{
66+
SetBackgroundColour(wxColor(80,100,255));
67+
SetBackgroundStyle(wxBG_STYLE_PAINT);
68+
// set the frame icon
69+
QuitBut = new wxButton(this, BUTTON_Quit, wxT("Ukonèit"), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxBU_EXACTFIT);
70+
QuitBut->SetForegroundColour(wxColor(150,150,255));
71+
int x, y;
72+
QuitBut->GetSize(&x, &y);
73+
QuitBut->SetPosition(wxPoint(640-x, 0));
74+
75+
76+
SetIcon(wxICON(sample));
77+
Centre();
78+
kamera = new Kamera();
79+
80+
}
81+
82+
void FrameMain::OnPaint(wxPaintEvent& event)
83+
{
84+
wxAutoBufferedPaintDC dc(this);
85+
dc.SetBackground(wxBrush(this->GetBackgroundColour()));
86+
dc.Clear();
87+
DrawImage(dc);
88+
}
89+
90+
void FrameMain::DrawImage(wxDC &dc)
91+
{
92+
93+
wxImage *image = new wxImage();
94+
kamera->Obrazek(image);
95+
96+
//image->Mirror(true);
97+
98+
99+
100+
wxSize imageSize = image->GetSize();
101+
wxBitmap bitmap = wxBitmap((image->Rotate180()));
102+
//delete image;
103+
dc.DrawBitmap(bitmap,0,0, false);
104+
}
105+
106+
// event handlers
107+
108+
void FrameMain::OnQuit(wxCommandEvent& WXUNUSED(event))
109+
{
110+
// true is to force the frame to close
111+
Close(true);
112+
}
113+
114+
115+
bool AppMain::OnInit()
116+
{
117+
// call the base class initialization method, currently it only parses a
118+
// few common command-line options but it could be do more in the future
119+
if ( !wxApp::OnInit() )
120+
return false;
121+
122+
// create the main application window
123+
FrameMain *frame = new FrameMain("Spektrograf");
124+
125+
// and show it (the frames, unlike simple controls, are not shown when
126+
// created initially)
127+
128+
//wxInitAllImageHandlers();
129+
130+
//wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
131+
132+
// then simply create like this
133+
//drawPane = new wxImagePanel( frame, wxT("image.jpg"), wxBITMAP_TYPE_JPEG);
134+
//sizer->Add(drawPane, 1, wxEXPAND);
135+
136+
//frame->SetSizer(sizer);
137+
frame->Show(true);
138+
139+
//kamera = new Kamera();
140+
141+
//kamera->Obrazek(img);
142+
143+
// success: wxApp::OnRun() will be called which will enter the main message
144+
// loop and the application will run. If we returned false here, the
145+
// application would exit immediately.
146+
return true;
147+
}

0 commit comments

Comments
 (0)