This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <opencv2/opencv.hpp> | |
#include <iostream> | |
using namespace cv; | |
using namespace cv::bgsubcnt; | |
using namespace std; | |
int main( int argc, char** argv ) | |
{ | |
VideoCapture cap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "bgsubcnt.h" | |
using namespace cv::bgsubcnt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rest of the code is the same ... | |
Ptr<BackgroundSubtractor> pBgSub = createBackgroundSubtractorCNT(); | |
// Rest of the code is the same ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ptr<BackgroundSubtractorCNT> | |
createBackgroundSubtractorCNT(int minPixelStability = 15, | |
bool useHistory = true, | |
int maxPixelStability = 15*60, | |
bool isParallel = true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
import bgsubcnt # 1. New import | |
# A temporary solution to OpenCV 3.1.0 bug | |
# with background subtractors | |
cv2.ocl.setUseOpenCL(False) | |
cap = cv2.VideoCapture('/home/userName/Downloads/opencv-3.1.0/samples/data/768x576.avi') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$1" = "-h" ]; then | |
echo "Usage: $0 [filename]" | |
exit | |
fi | |
# Get the IP automatically - this will prompt for a password because of sudo usage | |
ip=`sudo arp-scan -localnet | perl -ne 'print $1 if /(\S+).*Rigol/i'` | |
if [ "$ip" = "" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <thread> | |
#include <tbb/concurrent_queue.h> | |
#include <tbb/pipeline.h> | |
volatile bool done = false; // volatile is enough here. We don't need a mutex for this simple flag. | |
struct ProcessingChainData | |
{ | |
Mat img; | |
vector<Rect> faces, faces2; | |
Mat gray, smallImg; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
if( capture.isOpened() ) | |
{ | |
//... | |
tbb::concurrent_bounded_queue<ProcessingChainData *> guiQueue; | |
guiQueue.set_capacity(2); // TBB NOTE: flow control so the pipeline won't fill too much RAM | |
auto pipelineRunner = thread( detectAndDrawTBB, ref(capture), ref(guiQueue), ref(cascade), ref(nestedCascade), scale, tryflip ); | |
//... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TBB NOTE: This usage below is just for the tbb demonstration. | |
// It is not an example for good OO code. The lambda | |
// expressions are used to easily show the correleation | |
// between the original code and the tbb code. | |
void detectAndDrawTBB( VideoCapture &capture, | |
tbb::concurrent_bounded_queue<ProcessingChainData *> &guiQueue, | |
CascadeClassifier& cascade, | |
CascadeClassifier& nestedCascade, | |
double scale, bool tryflip ) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CountingManager | |
{ | |
public: | |
CountingManager(Canvas &c) | |
{ | |
c.notifyOnShapeCreate([&c, this](Shape* shape) | |
{ // User created a shape | |
if (shape->getType() == LineCrossing::type) | |
{ // Add the LineCrossing to out list | |
LineCrossing *pLineCrossing = (LineCrossing*) shape; |
OlderNewer