Hello All,
I will be more than grateful if you could find time for answering me.
General:I am writing a GUI, in which I receive real time video from several cameras of a robot (using ROS).
Hierarchy:Container (Gtk Widget) ---points to---> GtkTable (4x4) ---each of cells points to---> EventBox (GtkWidget)
---points to--->GtkWidget ---points to---> GtkPixbuf ---points to---> IplImage (for each frame of the video).
Problem:Until now, I have only showed real time video stream, and everything worked properly.
Here is the code of the main loop.
Code:
int main(int argc, char **argv)
{
ros::init(argc, argv, "image_listener");
ros::NodeHandle nh;
ros::Rate loop_rate(100); // Rate class instance.
ImageManagmentStruct LeftCameraImageStruct, RightCameraImageStruct, KinectImageStruct; // Structs for image menagment.
// Getting the resizing parameter from the launch file.
if ( !nh.getParam("resizing_factor", globalResizingFactor) )
{
ROS_ERROR ("The resizing factor was not loaded succesfully. Aborting...\n");
ros::shutdown();
}
// Initializing the image/camera data structures.
dataStructuresInitialization ( &LeftCameraImageStruct, &RightCameraImageStruct, &KinectImageStruct );
// GTK library initialization
gtk_init ( &argc, &argv );
// Creating a top level window and connecting it to a signal.
createMainInterfaceWindow ();
// Creating a fixed container, which will hold all the widgets of the GUI.
createFixedContainer ();
// Creating a GtkGrid widget, which will contain all the images.
createGtkTable ();
// Attaching the created table to the Container.
gtk_fixed_put (GTK_FIXED (pGlobalFixedContainer), pGlobalGtkTable, IMAGES_HORIZONTAL_PLACEMENT, IMAGES_VERTIACL_PLACEMENT);
// Subscribing in order to receive images.
ros::Subscriber subLeft = nh.subscribe<sensor_msgs::Image> ("leftCameraTopic", 10, boost::bind(imageCallback, _1, globalArrayOfImages[0]));
ros::Subscriber subRight = nh.subscribe<sensor_msgs::Image> ("rightCameraTopic", 10, boost::bind(imageCallback, _1, globalArrayOfImages[1]));
ros::Subscriber subKinect = nh.subscribe<sensor_msgs::Image> ("kinectCameraTopic", 10, boost::bind(imageCallback, _1, globalArrayOfImages[2]));
while ( ros::ok() )
{
// Showing the main window, with the attached image.
if ( GTK_IS_WIDGET (globalTopLevelWindow) )
{
gtk_widget_show_all ( globalTopLevelWindow );
}
else
{
ROS_INFO ("The top level window of the application was closed...Exiting the program.\n");
return 0;
}
// Allowing "imageCallback" to be called.
ros::spinOnce();
// Running the main GTK iteration loop.
gtk_main_iteration_do(0);
// Sleep
loop_rate.sleep ();
}
return 0;
}
Goal:Zoom in/Zoom out each image independently via mouse clicking.
Idea:On a click, hide the GtkTable and create a different GtkWidget with the relevant image inside.
Problem:The "gtk_widget_show_all ( globalTopLevelWindow )" in the main loop is WRONG and I need to place it in a different place, I probably need to show the widgets in a different way, but in such a way, that in one hand the video stream will always be updated, and on the other hand, the widgets will be independent...
Question:What is the correct way to achieve the needed goal?
Thank you all in advance,
Felix.