本文整理汇总了C++中Director::performRegionScan方法的典型用法代码示例。如果您正苦于以下问题:C++ Director::performRegionScan方法的具体用法?C++ Director::performRegionScan怎么用?C++ Director::performRegionScan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::performRegionScan方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
//ActuatorController ac("/dev/tty.usbserial-A9S3VTXD");
//ac.init();
sf::Clock clock;
sf::RenderWindow window(sf::VideoMode(640,480), "test");
bool isAdding = false;
bool area_selected = false;
Director director;
std::vector<cv::Vec2d> pointsList;
std::vector<cv::Vec2d> area_points;
std::vector<cv::Vec2d> selected_points;
std::vector<ActuatorMoveOrder> ordersList;
while (window.isOpen())
{
// check all the window's events that were triggered since the last iteration of the loop
sf::Event event;
while (window.pollEvent(event))
{
sf::Time time1 = clock.getElapsedTime();
director.update();
if (event.type == sf::Event::MouseButtonPressed) {
if(isAdding) {
//When in adding mode, add position of where mouse clicked to a vector.
cv::Vec2d point = cv::Vec2d(-150+300.0*((double)event.mouseButton.x)/640.0, -90.0+180*((double)event.mouseButton.y)/480.0);
std::cout << point[0] << ',' << point[1] << std::endl;
pointsList.push_back(point);
cv::Vec2d mouse_pos = {(double)event.mouseButton.x, (double)event.mouseButton.y};
selected_points.push_back(mouse_pos);
}
else {
//When not in adding mode, send order to manualPan function to move actuator.
cv::Vec2d point = cv::Vec2d(-150+300.0*((double)event.mouseButton.x)/640.0, -90.0+180*((double)event.mouseButton.y)/480.0);
std::cout << point[0] << ',' << point[1] << std::endl;
ActuatorMoveOrder order;
order.posDeg = point;
order.duration = 2;
director.performManualPan(order);
std::cout << time1.asSeconds() << std::endl;
}
}
else if (event.type == sf::Event::KeyPressed) {
if (event.key.code == sf::Keyboard::Escape) {
window.close();
}
else if(event.key.code == sf::Keyboard::A) {
// When A is pressed, window is in adding mode
isAdding = true;
}
else if(event.key.code == sf::Keyboard::S) {
//Draw box, Scan region
director.performRegionScan(pointsList);
area_points = director.getSelectedRegion();
pointsList.clear();
isAdding = false;
area_selected = true;
}
else if(event.key.code == sf::Keyboard::D) {
//FullScan
ordersList = director.performFullScan();
}
else if(event.key.code == sf::Keyboard::C) {
//Empty everything and stop
area_points.clear();
selected_points.clear();
ordersList.clear();
isAdding = false;
area_selected = false;
director.haltMovement();
}
}
else if (event.type == sf::Event::Closed) {
window.close();
}
}
window.clear();
//Acuator Position
cv::Vec2d pos;
pos = director.getCurrentPositionAC();
//std::cout << pos << std::endl;
auto actPos = sf::Vector2f((pos[0]+150.0)/300.0*640.0, (pos[1]+90.0)/180.0*480.0);
sf::CircleShape actuator;
actuator.setRadius(2);
actuator.setFillColor(sf::Color::Green);
actuator.setPosition(actPos);
window.draw(actuator);
sf::Vector2f prevPos;
//Actuator move path - create lines
for(int j = 0; j < ordersList.size(); j++) {
//.........这里部分代码省略.........