当前位置: 首页>>代码示例>>C++>>正文


C++ OpticalFlow::init方法代码示例

本文整理汇总了C++中OpticalFlow::init方法的典型用法代码示例。如果您正苦于以下问题:C++ OpticalFlow::init方法的具体用法?C++ OpticalFlow::init怎么用?C++ OpticalFlow::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpticalFlow的用法示例。


在下文中一共展示了OpticalFlow::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setup

void setup()
{
    hal.console->printf("OpticalFlow library test ver 1.6\n");

    hal.scheduler->delay(1000);

    // flowSensor initialization
    optflow.init();

    if (!optflow.healthy()) {
        hal.console->printf("Failed to initialise PX4Flow ");
    }

    hal.scheduler->delay(1000);
}
开发者ID:BrendanSmith,项目名称:ardupilot,代码行数:15,代码来源:AP_OpticalFlow_test.cpp

示例2: displayImage

int
main(int argc, char **argv)
{
  OpticalFlow optFlow;

  cv::Mat mu_x, mu_y;
  cv::Mat Lambda_xx, Lambda_xy, Lambda_yy;

  // Timing variables
  double gpuTime, gpuAccumTime = 0.0;
  double totalWeight = 0.0, fps = 0;;
  unsigned int timer;
  CUT_SAFE_CALL( cutCreateTimer(&timer) );

  /* *
   * Optical flow algorithm parameters
   * */
  float lambdaZero  = 0.15;
  float lambdaOne   = 0.5;
  float lambdaTwo   = 0.5;
  float lambdaPrior = 0.1;
  int windowSide    = 3;


  /* *
   * Process command line arguments
   * */
  if((argc == 2) and ((strcmp(argv[1], "-h") == 0) or (strcmp(argv[1], "--help") == 0))) {
    std::cerr << "Usage:\n\t" << argv[0] << " <movie.avi>" << std::endl;
    return EXIT_FAILURE;
  }

  /* *
   * Load movie, or capture from cam
   * */
  cv::VideoCapture capture;
  if(argc == 2) {
    capture.open(argv[1]);
    if(not capture.isOpened()) {
      std::cerr << "Could not open file " << argv[1] << std::endl;
      return EXIT_FAILURE;
    }
  } else {
    capture.open(0); // Any camera is good
    CB_PRINT_VAR(capture.isOpened());
    if(not capture.isOpened()) {
      std::cerr << "Could not capture from camera." << std::endl;
      return EXIT_FAILURE;
    }
  }


  cv::Mat frame;
  cv::Size frameSize;

  cv::Mat frames[3], auxBW;
  int prevIdx = 0, currIdx = 1, nextIdx = 2;

  capture >> frame; //framePtr = cvQueryFrame(capture);
  
  frameSize = frame.size();// cvGetSize(framePtr);

  
  // garantee that the smallest image side is bigger than 32 pixels
  int maxLevels = int( log(MIN(frameSize.width, frameSize.height))/log(2.0) - 4.0 );
  int nLevels   = maxLevels;

  auxBW.create(frameSize, CV_8UC1);
  for(int i = 0; i < 3; i++)
    frames[i].create(frameSize, CV_32FC1);

  mu_x.create(frameSize, CV_32FC1);//IPL_DEPTH_32F, 1);
  mu_y.create(frameSize, CV_32FC1);//, IPL_DEPTH_32F, 1);
  Lambda_xx.create(frameSize, CV_32FC1);//, IPL_DEPTH_32F, 1);
  Lambda_yy.create(frameSize, CV_32FC1);//, IPL_DEPTH_32F, 1);
  Lambda_xy.create(frameSize, CV_32FC1);//, IPL_DEPTH_32F, 1);

  cv::cvtColor(frame, auxBW, CV_BGR2GRAY);  
  auxBW.convertTo(frames[prevIdx], CV_32FC1, 1/255.0);

  capture >> frame;
  cv::cvtColor(frame, auxBW, CV_BGR2GRAY);  
  auxBW.convertTo(frames[currIdx], CV_32FC1, 1/255.0);

  optFlow.init(frames[prevIdx], frames[currIdx],
	       nLevels, windowSide,
	       lambdaZero, lambdaOne, lambdaTwo, lambdaPrior);

  /* *
   * Simple GUI
   * */
  CvPoint textCorner = cvPoint(20, 20);
  
  int pressedKey = 0;
  const char *displayWindowName = "Optical Flow Demo";
  const char *controlWindowName = "Optical Flow Controls";

  CvSize infoImageSize = cvSize(300, 200);

  cvNamedWindow(displayWindowName, 0);
//.........这里部分代码省略.........
开发者ID:Anantak,项目名称:CUDABOF,代码行数:101,代码来源:test04_opticalFlow.cpp


注:本文中的OpticalFlow::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。