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


C++ NumberArray::setSize方法代码示例

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


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

示例1: main

int main( int argc, const char** argv )
{
	// Flags for various UI features
	bool pause = false;       // pause playback?
	bool printFrames = false; // print frame number?
	int frameDisplayFrequency = 1;
   
	// Read through command line args, extract
	// cmd line parameters and input filename
	Args args;

	if (!args.processArgs(argc, argv))
		return -2;

	string windowName = "Bin detection"; // GUI window name
	string capPath; // Output directory for captured images
	MediaIn* cap;
	openMedia(args.inputName, cap, capPath, windowName, !args.batchMode);

	if (!args.batchMode)
		namedWindow(windowName, WINDOW_AUTOSIZE);

	// Seek to start frame if necessary
	if (args.frameStart > 0)
		cap->frameCounter(args.frameStart);

	Mat frame;

	// Minimum size of a bin at ~30 feet distance
	// TODO : Verify this once camera is calibrated
	if (args.ds)	
	   minDetectSize = cap->width() * 0.07;
	else
	   minDetectSize = cap->width() * 0.195;

	// If UI is up, pop up the parameters window
	if (!args.batchMode)
	{
		string detectWindowName = "Detection Parameters";
		namedWindow(detectWindowName);
		createTrackbar ("Scale", detectWindowName, &scale, 50, NULL);
		createTrackbar ("Neighbors", detectWindowName, &neighbors, 50, NULL);
		createTrackbar ("Min Detect", detectWindowName, &minDetectSize, 200, NULL);
		createTrackbar ("Max Detect", detectWindowName, &maxDetectSize, max(cap->width(), cap->height()), NULL);
	}

	// Create list of tracked objects
	// recycling bins are 24" wide
	TrackedObjectList binTrackingList(24.0, cap->width());

	NetworkTable::SetClientMode();
	NetworkTable::SetIPAddress("10.9.0.2"); 
	NetworkTable *netTable = NetworkTable::GetTable("VisionTable");
	const size_t netTableArraySize = 7; // 7 bins?
	NumberArray netTableArray;

	// 7 bins max, 3 entries each (confidence, distance, angle)
	netTableArray.setSize(netTableArraySize * 3);

	// Code to write video frames to avi file on disk
	VideoWriter outputVideo;
	VideoWriter markedupVideo;
	args.writeVideo = netTable->GetBoolean("WriteVideo", args.writeVideo);
	const int videoWritePollFrequency = 30; // check for network table entry every this many frames (~5 seconds or so)
	int videoWritePollCount = videoWritePollFrequency;

	FrameTicker frameTicker;

	DetectState detectState(
		  ClassifierIO(args.classifierBaseDir, args.classifierDirNum, args.classifierStageNum), 
		  gpu::getCudaEnabledDeviceCount() > 0);
	// Start of the main loop
	//  -- grab a frame
	//  -- update the angle of tracked objects 
	//  -- do a cascade detect on the current frame
	//  -- add those newly detected objects to the list of tracked objects
	while(cap->getNextFrame(frame, pause))
	{
		frameTicker.start(); // start time for this frame
		if (--videoWritePollCount == 0)
		{
			args.writeVideo = netTable->GetBoolean("WriteVideo", args.writeVideo);
			videoWritePollCount = videoWritePollFrequency;
		}

		if (args.writeVideo)
		   writeVideoToFile(outputVideo, getVideoOutName().c_str(), frame, netTable, true);

		//TODO : grab angle delta from robot
		// Adjust the position of all of the detected objects
		// to account for movement of the robot between frames
		double deltaAngle = 0.0;
		binTrackingList.adjustAngle(deltaAngle);

		// This code will load a classifier if none is loaded - this handles
		// initializing the classifier the first time through the loop.
		// It also handles cases where the user changes the classifer
		// being used - this forces a reload
		// Finally, it allows a switch between CPU and GPU on the fly
		if (detectState.update() == false)
//.........这里部分代码省略.........
开发者ID:Aerobota,项目名称:2015VisionCode,代码行数:101,代码来源:test.cpp


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