Select Git revision
VideoCapture.cpp
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
VideoCapture.cpp 8.14 KiB
/*
This file is part of BGSLibrary.
BGSLibrary is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BGSLibrary is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
*/
#include "VideoCapture.h"
#include <opencv2/highgui/highgui_c.h>
namespace bgslibrary
{
namespace VC_ROI
{
IplImage* img_input1 = 0;
IplImage* img_input2 = 0;
int roi_x0 = 0;
int roi_y0 = 0;
int roi_x1 = 0;
int roi_y1 = 0;
int numOfRec = 0;
int startDraw = 0;
bool roi_defined = false;
bool use_roi = true;
bool disable_event = false;
void reset(void)
{
disable_event = false;
startDraw = false;
}
void VideoCapture_on_mouse(int evt, int x, int y, int flag, void* param)
{
if (use_roi == false || disable_event == true)
return;
if (evt == CV_EVENT_LBUTTONDOWN)
{
if (!startDraw)
{
roi_x0 = x;
roi_y0 = y;
startDraw = 1;
}
else
{
roi_x1 = x;
roi_y1 = y;
startDraw = 0;
roi_defined = true;
disable_event = true;
}
}
if (evt == CV_EVENT_MOUSEMOVE && startDraw)
{
//redraw ROI selection
img_input2 = cvCloneImage(img_input1);
cvRectangle(img_input2, cvPoint(roi_x0, roi_y0), cvPoint(x, y), CV_RGB(255, 0, 0), 1);
cvShowImage("Input", img_input2);