Webcam Tracker  V1.0
Using openCV and an Arduino Uno
Public Member Functions | Private Attributes | List of all members

Opens the webcam and captures its feed if available. More...

#include <Capture.h>

Public Member Functions

 Capture ()
 Default constructor.
 
 Capture (int deviceID, int apiID)
 Constructor. More...
 
int getFeed (cv::Mat &src)
 gets the webcam feed More...
 

Private Attributes

cv::VideoCapture cap
 Object holding the capture device.
 
int deviceId
 Device identification number.
 
int apiId
 Device capture API identification number.
 
cv::Mat src
 Object holding the capture image(source)
 
bool deviceOpened
 Device opened flag.
 

Detailed Description

Opens the webcam and captures its feed if available.

Constructor & Destructor Documentation

◆ Capture()

Capture::Capture ( int  deviceID,
int  apiID 
)

Constructor.

Parameters
deviceIDnumber of the device
apiIDdevice capture API number
21  {
22  this->deviceId = deviceID;
23  this->apiId = apiId;
24 
25  cap.open(this->deviceId + this->apiId);
26  deviceOpened = false;
27 
28  if (!cap.isOpened()) {
29  std::cerr << "ERROR: Can't open camera feed" << std::endl;
30  }
31  else {
32  std::cout << "Camera feed opened" << std::endl;
33  deviceOpened = true;
34  }
35 }
int apiId
Device capture API identification number.
Definition: Capture.h:19
int deviceId
Device identification number.
Definition: Capture.h:18
bool deviceOpened
Device opened flag.
Definition: Capture.h:21
cv::VideoCapture cap
Object holding the capture device.
Definition: Capture.h:17

Member Function Documentation

◆ getFeed()

int Capture::getFeed ( cv::Mat &  src)

gets the webcam feed

Parameters
srcPointer to a source OpenCV matrix
Returns
succes or error
37  {
38  if (deviceOpened) {
39  cap.read(this->src);
40 
41  if (this->src.empty()) {
42  std::cerr << "ERROR: Frame is blank" << std::endl;
43  return -1;
44  }
45  else {
46  src = this->src;
47  return 1;
48  }
49  }
50  else {
51  std::cerr << "ERROR: No device opened" << std::endl;
52  return -2;
53  }
54 }
cv::Mat src
Object holding the capture image(source)
Definition: Capture.h:20
Here is the caller graph for this function: