⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.cpp

📁 机器人程序
💻 CPP
字号:
/// tests looking for a Haar Face and getting all sightings

#define USE_OPENCVINTERFACE



#include <stdio.h>
#include <windows.h>
#include "MVLib.h"
#include "maviscomm.h"
#include "Mavis.h"
#include "MavisErr.h"

// mavis proper
Mavis * pMavis       = NULL;
HANDLE  hMavisThread = NULL;

// mavis client
HINSTANCE    mavisLib     = NULL;
LOOKONCEPROC procLookOnce = NULL;

// function prototypes
DWORD WINAPI RunMavis(LPVOID lpThreadData);


int main(int argc, char** argv)
{
	// initialize Mavis
	/*try
	{
		pMavis = new Mavis();
	}
	catch(MavisErr& e)
	{
		string msg = "Error: ";
		msg += e.getMsg();
		cout << msg << endl;
		return -1;
	}
	catch(...) {
		cout << "Can't initialize Mavis - unknown error\n";
		return -1;
	}

	// run Mavis in its own thread
	hMavisThread = CreateThread(
		NULL,          //default security attributes
		0,             //default stack size
		RunMavis,      //thread function
		NULL,          //the thread data
		0,             //default creation flags
		NULL           //thread id variable
	);*/


	// load the communications dll
	try
	{
		mavisLib = LoadLibrary("mavisclient");
		if(NULL == mavisLib) throw MavisErr( "can't load mavisclient.dll" );

		procLookOnce = (LOOKONCEPROC)GetProcAddress(mavisLib, LOOKONCEPROC_NAME);
		if(NULL == procLookOnce)
			throw MavisErr( "can't access mavisclient.dll method for LOOKONCEPROC" );
	}
	catch(MavisErr& e)
	{
		string msg = "Error: ";
		msg += e.getMsg();
		cout << msg << endl;
		goto cleanup;
	}


	// do look once
	ObjLoc_t objLoc;
	procLookOnce(HAAR_FACE_DETECTOR_ID, &objLoc);

	/*double angle;     // heading to reach the object, degrees (cw is pos, ccw neg)
	double dist;      // object's estimated distance from robot, mm
	int prob;         // a confidence level for the sighting (0 means no sighting)
	int movFlag;      // a flag indicating a move is needed for a better view
	double movAngle;  // heading for the move
	double movDist;   // distance to move

	int nFound;       // how many of these were detected
	int nRemaining;   // how many unretrieved detections remain

	int xlo;          // for objects that are localized and have spatial extent,
	int xhi;          //     these are the image coordinates. The origin is
	int ylo;          //     at the lower-left corner of the image.
	int yhi;*/

	cout << "objLoc.angle = " << objLoc.angle << endl;
	cout << "objLoc.prob = " << objLoc.prob << endl;
	cout << "objLoc.movFlag = " << objLoc.movFlag << endl;
	cout << "objLoc.movDist = " << objLoc.movDist << endl;
	cout << "objLoc.nFound = " << objLoc.nFound << endl;
	cout << "objLoc.nRemaining = " << objLoc.nRemaining << endl;
	cout << "objLoc.xlo = " << objLoc.xlo << endl;
	cout << "objLoc.xhi = " << objLoc.xhi << endl;
	cout << "objLoc.ylo = " << objLoc.ylo << endl;
	cout << "objLoc.yhi = " << objLoc.yhi << endl;



cleanup:
	if(mavisLib) FreeLibrary(mavisLib);
	if(pMavis)
	{
		pMavis->stop();
		Sleep(60L);
		if(hMavisThread) CloseHandle(hMavisThread);
		delete pMavis;
	}

	return 0;
}


////////////
// thread function to run mavis
//
DWORD WINAPI RunMavis(LPVOID lpThreadData)
{
	if(pMavis) pMavis->run();
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -