void TriangleTransform::onActionTransform()
{
	if (!this->srcImgArea->isImgEmpty())
	{
	
		ImageTransform imgTrans(this->srcImgArea->filePath);
		imgTrans.setType(TRIANGLETRANS);
		std::vector<Wml::Vector2f> src, dst;
		std::cout << "src" << std::endl;
		for (int i = 0; i < 3; i++)
		{
			src.push_back(Wml::Vector2f(this->srcImgArea->triPoint[i][0], this->srcImgArea->triPoint[i][1]));
			
		}
		
		int h = this->srcImgArea->imgHeigth;
		int w = this->srcImgArea->imgWidth;

		dst.push_back(Wml::Vector2f(w*0.5, h*0.2));
		dst.push_back(Wml::Vector2f(w*0.1, h*0.5));
		dst.push_back(Wml::Vector2f(w*0.7, h*0.7));
		for (int i = 0; i < src.size(); i++)
		{
			src[i][1] = h-1 - src[i][1];
			dst[i][1] = h-1 - dst[i][1];
		}
		imgTrans.setTriangleTransPoint(src, dst);
		
		imgTrans.doTransform();
		//imgTrans.testCopyToDstImg();
		this->dstImgArea->loadFromBoxPartImage(imgTrans.getBoxPartImage());
		this->dstImgArea->update();
	}
}
Ejemplo n.º 2
0
NavigationNode::NavigationNode(NavigationGUI *newgui) {
	ROS_INFO("Starting Navigation Node");
	gui = newgui;
	//a nodehandler is used to communiate with the rest of ros
	ros::NodeHandle n("~");
    image_transport::ImageTransport imgTrans(n);
	
	//Initialise all the information to be used in by the gui
	battery = 6;
	signal = 6;
	tiltX = 30;
	tiltY = 30;
	ultrasonic = 0;
	
	//Initialise the feeds array
	for(int i = 0; i < TOTAL_FEEDS; i++)
		feeds[i] = FEED_OFFLINE;
	
	// 
	// Subscribe to all relevant topics for information used by the gui
	// pass the function that is called when a message is received into the subscribe function
	// 
	
	gpsSub = n.subscribe("/gps/fix", 1000, &NavigationNode::receiveGpsMsg, this); // GPS related data
	batterySub = n.subscribe("/status/battery", 1000, &NavigationNode::receiveBatteryMsg, this); // Power left on the battery
	feedsSub = n.subscribe("/owr/control/availableFeeds", 1000, &NavigationNode::receiveFeedsStatus, this);
	
	// Subscribe to all topics that will be published to by cameras, if the topic hasnt been
	// created yet, will wait til it has w/o doing anything

	//ros::TransportHints transportHints = ros::TransportHints().tcpNoDelay();
	//image_transport::TransportHints transportHints = ros::TransportHints().tcpNoDelay();

        // Frames of video from camera
	videoSub[0] = imgTrans.subscribe("/cam0", 1, &NavigationNode::receiveVideoMsg, this, image_transport::TransportHints("compressed"));
	videoSub[1] = imgTrans.subscribe("/cam1", 1, &NavigationNode::receiveVideoMsg, this, image_transport::TransportHints("compressed"));
	videoSub[2] = imgTrans.subscribe("/cam2", 1, &NavigationNode::receiveVideoMsg, this, image_transport::TransportHints("compressed"));
	videoSub[3] = imgTrans.subscribe("/cam3", 1, &NavigationNode::receiveVideoMsg, this, image_transport::TransportHints("compressed"));

}