# HG changeset patch # User Nicolas Saunier # Date 1464728843 14400 # Node ID c5f98916297edef000a19d9e7d25bfa248a34a77 # Parent a34ec862371fc053078d6e87b5b63f6bbc1fb481# Parent 2cade72d75ad95eda3d4de19113aca2621975120 merged with dev branch diff -r a34ec862371f -r c5f98916297e c/feature-based-tracking.cpp --- a/c/feature-based-tracking.cpp Mon May 09 15:33:11 2016 -0400 +++ b/c/feature-based-tracking.cpp Tue May 31 17:07:23 2016 -0400 @@ -62,10 +62,6 @@ } void trackFeatures(const KLTFeatureTrackingParameters& params) { - // BriefDescriptorExtractor brief(32); - // const int DESIRED_FTRS = 500; - // GridAdaptedFeatureDetector detector(new FastFeatureDetector(10, true), DESIRED_FTRS, 4, 4); - Mat homography = ::loadMat(params.homographyFilename, " "); Mat invHomography; if (params.display && !homography.empty()) @@ -174,8 +170,7 @@ break; } } - - + cvtColor(frame, currentFrameBW, CV_RGB2GRAY); if (!prevPts.empty()) { @@ -188,9 +183,9 @@ while (iter != featurePointMatches.end()) { bool deleteFeature = false; - if (status[iter->pointNum]) { + if (status[iter->pointNum] && (mask.at(static_cast(round(currPts[iter->pointNum].y)), static_cast(round(currPts[iter->pointNum].x))) != 0)) { iter->feature->addPoint(frameNum, currPts[iter->pointNum], homography); - + deleteFeature = iter->feature->isDisplacementSmall(params.nDisplacements, minTotalFeatureDisplacement) || !iter->feature->isMotionSmooth(params.accelerationBound, params.deviationBound); if (deleteFeature) @@ -219,14 +214,9 @@ if (params.display) { BOOST_FOREACH(FeaturePointMatch fp, featurePointMatches) fp.feature->draw(frame, invHomography, Colors::red()); - // object detection - // vector locations; - // hog.detectMultiScale(frame, locations, 0, Size(8,8), Size(32,32), 1.05, 2); - // BOOST_FOREACH(Rect r, locations) - // rectangle(frame, r.tl(), r.br(), cv::Scalar(0,255,0), 3); } } - + // adding new features, using mask around existing feature positions Mat featureMask = mask.clone(); for (unsigned int n=0;n(i,j)=0; goodFeaturesToTrack(currentFrameBW, newPts, params.maxNFeatures, params.featureQuality, params.minFeatureDistanceKLT, featureMask, params.blockSize, params.useHarrisDetector, params.k); - BOOST_FOREACH(Point2f p, newPts) { //for (unsigned int i=0; i0: + if img is not None and img.size>0: if saveImage: - imgNumStr = format(firstFrameNum+imgNum, '0{}d'.format(nDigits)) - cv2.imwrite(outputPrefix+imgNumStr+'.png', img) + frameNumStr = format(frameNum, '0{}d'.format(nDigits)) + cv2.imwrite(outputPrefix+frameNumStr+'.png', img) else: images.append(img) - imgNum +=1 + frameNum +=step + if step > 1: + capture.set(cv2.CAP_PROP_POS_FRAMES, frameNum) capture.release() else: print('Video capture for {} failed'.format(videoFilename)) diff -r a34ec862371f -r c5f98916297e python/traffic_engineering.py --- a/python/traffic_engineering.py Mon May 09 15:33:11 2016 -0400 +++ b/python/traffic_engineering.py Tue May 31 17:07:23 2016 -0400 @@ -309,7 +309,11 @@ def uniformDelay(cycleLength, effectiveGreen, saturationDegree): '''Computes the uniform delay''' - return 0.5*cycleLength*(1-float(effectiveGreen)/cycleLength)/(1-float(effectiveGreen*saturationDegree)/cycleLength) + return 0.5*cycleLength*(1-float(effectiveGreen)/cycleLength)**2/(1-float(effectiveGreen*saturationDegree)/cycleLength) + +def randomDelay(volume, saturationDegree): + '''Computes the random delay = queueing time for M/D/1''' + return saturationDegree**2/(2*volume*(1-saturationDegree)) def incrementalDelay(T, X, c, k=0.5, I=1): '''Computes the incremental delay (HCM)