Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
VideoProcessor.cpp
Package: cvOnMFC.rar [view]
Upload User: huiyuanjf
Upload Date: 2022-05-15
Package Size: 132k
Code Size: 2k
Category:
OpenCV
Development Platform:
Visual C++
- #include "StdAfx.h"
- #include "VideoProcessor.h"
- using namespace cv;
- UINT ProcessFunction(LPVOID lpParam)
- {
- VideoProcessor *proc = (VideoProcessor*)lpParam;
- while (true)
- {
- proc->Capture();
- proc->Process();
- //proc->Display();
- if (WaitForSingleObject(proc->eventStop, 0) == WAIT_OBJECT_0)
- {
- break;
- }
- }
- return 0;
- }
- VideoProcessor::VideoProcessor()
- {
- isRunning = false;
- }
- VideoProcessor::~VideoProcessor()
- {
- Stop();
- }
- void VideoProcessor::Start(int deviceIndex)
- {
- if (isRunning == true)
- {
- return;
- }
- cap = new VideoCapture(deviceIndex);
- if (cap->isOpened() == false)
- {
- return;
- }
- eventStop = CreateEvent(NULL, FALSE, NULL,NULL);
- procThread = AfxBeginThread(ProcessFunction, this);
- isRunning = true;
- return;
- }
- void VideoProcessor::Stop()
- {
- if (isRunning == false)
- {
- return;
- }
- SetEvent(eventStop);
- WaitForSingleObject(procThread->m_hThread, INFINITE);
- delete cap;
- CloseHandle(eventStop);
- isRunning = false;
- }
- bool VideoProcessor::IsRunning()
- {
- return isRunning;
- }
- void VideoProcessor::Capture()
- {
- if (isRunning == false)
- {
- return;
- }
- Mat imgOrg;
- (*cap) >> imgOrg;
- resize(imgOrg, imgSrc, Size(480, 360));
- return;
- }
- void VideoProcessor::Process()
- {
- if (isRunning == false)
- {
- return;
- }
- Mat src = imgSrc;
- Mat dst;
- dilate(src, dst, Mat());
- imgDst = dst;
- return;
- }
- void VideoProcessor::Display()
- {
- imshow("Image", imgDst);
- HWND hWnd= (HWND)cvGetWindowHandle("Image");
- SendMessage(hWnd,WM_PAINT,NULL,NULL);
- }