本文整理汇总了C++中OpticalFlow::setLambdaTwo方法的典型用法代码示例。如果您正苦于以下问题:C++ OpticalFlow::setLambdaTwo方法的具体用法?C++ OpticalFlow::setLambdaTwo怎么用?C++ OpticalFlow::setLambdaTwo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpticalFlow
的用法示例。
在下文中一共展示了OpticalFlow::setLambdaTwo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displayImage
//.........这里部分代码省略.........
cvMoveWindow(controlWindowName, frameSize.width + 30, infoImageSize.height + 60);
cv::Mat displayImage(frameSize, CV_8UC3);//IPL_DEPTH_8U, 3);
cv::Mat infoImage(infoImageSize, CV_8UC3);//, IPL_DEPTH_8U, 3);
int lineMulFactor = 1, ellipseMulFactor = 0, gridSpacing = 10; // Optical flow drawing parameters
int lambdaZero_x_1000 = int(1000.0 * lambdaZero);
int lambdaOne_x_1000 = int(1000.0 * lambdaOne);
int lambdaTwo_x_1000 = int(1000.0 * lambdaTwo);
int lambdaPrior_x_1000 = int(1000.0 * lambdaPrior);
cvCreateTrackbar("line mul factor", controlWindowName, &lineMulFactor, 10000, NULL);
cvCreateTrackbar("ellipse mul factor", controlWindowName, &ellipseMulFactor, 80, NULL);
cvCreateTrackbar("grid spacing", controlWindowName, &gridSpacing, 100, NULL);
cvCreateTrackbar("lambdaZero x 1000", controlWindowName, &lambdaZero_x_1000, 2000, NULL);
cvCreateTrackbar("lambdaOne x 1000", controlWindowName, &lambdaOne_x_1000, 2000, NULL);
cvCreateTrackbar("lambdaTwo x 1000", controlWindowName, &lambdaTwo_x_1000, 2000, NULL);
cvCreateTrackbar("lambdaPrior x 1000", controlWindowName, &lambdaPrior_x_1000, 2000, NULL);
cvCreateTrackbar("n levels", controlWindowName, &nLevels, maxLevels, NULL);
std::cout << "Press ESC to exit." << std::endl;
while((pressedKey = cvWaitKey(10)) != 'q') { //CB_ESC) {
gridSpacing = MAX(gridSpacing, 1);
nLevels = MAX(nLevels, 1);
lambdaZero = float(lambdaZero_x_1000) / 1000.0;
lambdaOne = float(lambdaOne_x_1000) / 1000.0;
lambdaTwo = float(lambdaTwo_x_1000) / 1000.0;
lambdaPrior = float(lambdaPrior_x_1000) / 1000.0;
optFlow.setLambdaZero(lambdaZero);
optFlow.setLambdaOne(lambdaOne);
optFlow.setLambdaTwo(lambdaTwo);
optFlow.setLambdaPrior(lambdaPrior);
capture >> frame;
if(frame.empty()) break;
cv::cvtColor(frame, auxBW, CV_BGR2GRAY);
auxBW.convertTo(frames[nextIdx], CV_32FC1, 1/255.0);
/* *
* Compute optical flow
* */
if(optFlow.getNLevels() != nLevels) {
optFlow.init(frames[prevIdx], frames[currIdx],
nLevels, windowSide,
lambdaZero, lambdaOne, lambdaTwo, lambdaPrior);
}
CUT_SAFE_CALL( cutResetTimer(timer) );
CUT_SAFE_CALL( cutStartTimer(timer) );
optFlow(frames[nextIdx], mu_x, mu_y, Lambda_xx, Lambda_yy, Lambda_xy);
CUDA_SAFE_CALL( cudaThreadSynchronize() );
CUT_SAFE_CALL( cutStopTimer(timer) );
gpuTime = cutGetTimerValue(timer);
gpuAccumTime = gpuTime + 0.9 * gpuAccumTime;
totalWeight = 1.0 + 0.9 * totalWeight;
fps = totalWeight / (gpuAccumTime / 1000.0) /*gpuAccumTime is in ms*/;
fps = 1000 / gpuTime;
/* *
* Display results
* */
frame.convertTo(displayImage, CV_8UC3);
drawBayesianOpticalFlow(displayImage,
mu_x, mu_y,
Lambda_xx, Lambda_yy, Lambda_xy,
cvSize(gridSpacing, gridSpacing),
lineMulFactor, ellipseMulFactor);
int lineNo = 0;
infoImage.setTo(cv::Scalar(0,0,0));
drawText(infoImage, textCorner, lineNo++, "Press ESC to exit");
lineNo++;
drawLabelValuePair(infoImage, textCorner, lineNo++, "lambda zero", lambdaZero);
drawLabelValuePair(infoImage, textCorner, lineNo++, "lambda one", lambdaOne);
drawLabelValuePair(infoImage, textCorner, lineNo++, "lambda two", lambdaTwo);
drawLabelValuePair(infoImage, textCorner, lineNo++, "lambda prior", lambdaPrior);
drawLabelValuePair(infoImage, textCorner, lineNo++, "FPS", fps);
drawLabelValuePair(infoImage, textCorner, lineNo++, "n Levels", nLevels);
cv::imshow(displayWindowName, displayImage);
cv::imshow(controlWindowName, infoImage);
prevIdx = currIdx;
currIdx = nextIdx;
nextIdx = (nextIdx + 1)%3;
}
return EXIT_SUCCESS;
}