void handleFileAction( efsw::WatchID watchid, const std::string& dir, const std::string& filename, efsw::Action action, std::string oldFilename = "" ) { if (action == efsw::Actions::Modified) { WatcherEvent event(filename); queue->enqueue(event); } // std::cout << "DIR (" << dir + ") FILE (" + ( oldFilename.empty() ? "" : "from file " + oldFilename + " to " ) + filename + ") has event " << getActionName( action ) << std::endl; }
int main() { VideoCapture cap(CAMERA_NUMBER); // open the default camera SafeQueue<cv::Mat> *VideoFrameQueue = new SafeQueue<cv::Mat>; //Initialize our frame queue. if (cap.isOpened()) //If we were able to open the camera stream { //namedWindow(WINDOW_NAME, CV_WINDOW_AUTOSIZE); //create a window to display stream Initialize(VideoFrameQueue); //While we're grabbing frames from the camera Mat currentFrame; while (cap.read(currentFrame)) { if (currentFrame.data != NULL) { //If we're at the queue limit, wait until space frees up while (VideoFrameQueue->ptr().size() >= MAX_IMG_QUEUE_SIZE) { cout << "Images in video queue exceeded max size: " << MAX_IMG_QUEUE_SIZE << endl; Sleep(1000); } VideoFrameQueue->enqueue(currentFrame); //Add our video frame to the processing queue if (waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop { Destroy(); cvDestroyWindow(WINDOW_NAME.c_str()); break; } } Sleep(500); } } else { cout << "Unable to open camera stream."; } return 0; }
TEST_F(SignalTest, MultipleConnectionTypes) { cout << "Testing multiple connection types for single signal" << endl; Signal<BigThing> testSignal; cout << "Connecting signals" << endl; list<int> ids; ids.push_back(testSignal.connectSlot(ExecutorScheme::SYNCHRONOUS, pushToQueue)); ids.push_back(testSignal.connectSlot(ExecutorScheme::ASYNCHRONOUS, pushToQueue)); ids.push_back(testSignal.connectSlot(ExecutorScheme::STRAND, pushToQueue)); cout << "Emitting signal" << endl; BasicTimer bt; BasicTimer bt2; bt.start(); bt2.start(); BigThing bigthing; for (uint32_t i = 0; i < 10; i++) { testSignal.emitSignal(bigthing); } bt2.stop(); cout << "Dequeueing" << endl; for (int i = 0; i < 30; i++) { sq.dequeue(); } bt.stop(); cout << "Signals emitted" << endl; cout << "Total time for emission: " << bt2.getElapsedMilliseconds() << "ms" << endl; cout << "Total time for emission and processing: " << bt.getElapsedMilliseconds() << "ms" << endl; cout << "Average emission+processing time: " << bt.getElapsedMilliseconds() / 10.0 << "ms" << endl; ASSERT_LT(bt2.getElapsedSeconds(), 0.1); ASSERT_LT(bt.getElapsedSeconds(), 0.2); }
void pushToQueue(BigThing bt) { sq.enqueue(bt); }