Distortion parameters from vision sensor?

Typically: "How do I... ", "How can I... " questions
Post Reply
SeveQ
Posts: 34
Joined: 25 Jul 2013, 20:46

Distortion parameters from vision sensor?

Post by SeveQ » 25 Oct 2013, 07:12

Hey again,

I'm looking for a way to fill in the sensor_msgs/CameraInfo fields from a vision sensor. What's the best way to get the values for distortion parameters and everything ROS needs in order to work with it?

And thanks again!

Cheers,
Hendrik

coppelia
Site Admin
Posts: 7077
Joined: 14 Dec 2012, 00:25

Re: Distortion parameters from vision sensor?

Post by coppelia » 27 Oct 2013, 18:22

Hello Hendrik,

not sure about the distorsion parameter. The vision sensors are software sensors and normally ideal, i.e. no distorsion. I guess it also really depends on what the other application is relying on (what of those parameters the other application is really using), but maybe you can find some answers around OpenGL, since the vision sensors are using it.

Cheers

SeveQ
Posts: 34
Joined: 25 Jul 2013, 20:46

Re: Distortion parameters from vision sensor?

Post by SeveQ » 31 Oct 2013, 23:04

I somehow figured it out myself. The easiest way to get the required parameters is by using camera calibration tools provided by the corresponding ROS package and creating an appropriate checker board in V-REP by hand (I used a texture made with The Gimp).

rick187
Posts: 9
Joined: 02 Jul 2014, 08:55

Re: Distortion parameters from vision sensor?

Post by rick187 » 02 Jul 2014, 09:19

Hello Hendrik, you can find a simple way to compute the camera_info for a vision sensor in the ros plugin. In particular in the file ROS_server.cpp you can find the following code:

Code: Select all

if (publishers[pubI].cmdID==simros_strmcmd_get_vision_sensor_info)
			{
				int resol[2];
				int handle = publishers[pubI].auxInt1;
				if (simGetVisionSensorResolution(handle,resol)!=-1)
				{
					sensor_msgs::CameraInfo info;
					info.header.stamp = inf.headerInfo.stamp;
					char* objName=simGetObjectName(handle);
					info.header.frame_id = objNameToFrameId(objName);
					simReleaseBuffer(objName);
					info.width = resol[0];
					info.height = resol[1];
					simFloat view_angle = M_PI/4;
					const unsigned int viewing_angle_id = 1004;
					simGetObjectFloatParameter(handle, viewing_angle_id, &view_angle);
					double f_x = (info.width/2.) / tan(view_angle/2.);
					double f_y = f_x;

					info.distortion_model = sensor_msgs::distortion_models::PLUMB_BOB;
					info.D.resize(5);
					info.D[0] = 0;
					info.D[1] = 0;
					info.D[2] = 0;
					info.D[3] = 0;
					info.D[4] = 0;

					info.K[0] = f_x; info.K[1] =   0; info.K[2] = info.width/2;
					info.K[3] =   0; info.K[4] = f_y; info.K[5] = info.height/2;
					info.K[6] =   0; info.K[7] =   0; info.K[8] = 1;

					info.R[0] = 1; info.R[1] = 0; info.R[2] = 0;
					info.R[3] = 0; info.R[4] = 1; info.R[5] = 0;
					info.R[6] = 0; info.R[7] = 0; info.R[8] = 1;

					info.P[0] = info.K[0]; info.P[1] = 0;         info.P[2] = info.K[2]; info.P[3] = 0;
					info.P[4] = 0;         info.P[5] = info.K[4]; info.P[6] = info.K[5]; info.P[7] = 0;
					info.P[8] = 0;         info.P[9] = 0;         info.P[10] = 1;        info.P[11] = 0;

					publishers[pubI].generalPublisher.publish(info);
				}
I have however a related question: how can one set more advanced camera parameters such as different pixel sizes for x and y and non-centered coordinates of the focal axis? This is very important for simulating a real camera for which a simple single focal-length model is not sufficient.
Even the possibility to simulate distortion would be very useful.
I will ask this in a separate faq.

Post Reply