ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

videre_stereo_cam segmentation fault

asked 2011-03-23 11:17:04 -0500

Michael Skolarikis gravatar image

updated 2014-01-28 17:09:24 -0500

ngrennan gravatar image

Hi everyone,

I'm trying to make "videre_stereo_cam" package to work with a VIDERE STOC camera 6cm baseline. The problem is that videre_stereo_node crashes reporting a segmentation fault. I believe that something goes wrong when frame deinterlacing takes place, but I'm not sure.

Using SVS software for Linux, I can access the camera and get disparity image. Unfortunately, SVS is precompiled for 32bit architectures and Videre does not provide support for this product any more. My operating system is 64bit.

System Information:

  1. videre_stereo_cam svn revision 1290

  2. ROS Diamondback

  3. Linux 2.6.32-29-generic #58-Ubuntu SMP Fri Feb 11 20:52:10 UTC 2011 x86_64 GNU/Linux

  4. libdc1394-22 libdc1394-22-dev libdc1394-utils libraw1394-dev libraw1394-11

When I first tried to compile videre_stereo_cam, compilation failed.

[ rosmake ] No package specified.  Building ['videre_stereo_cam']      
[ rosmake ] Packages requested are: ['videre_stereo_cam']
[ rosmake ] Logging to directory/home/pandora/.ros/rosmake/rosmake_output-20110323-193106
[ rosmake ] Expanded args ['videre_stereo_cam'] to:
['videre_stereo_cam']                                                                                                        
[ rosmake ] Checking rosdeps compliance for packages videre_stereo_cam.  This may take a few seconds.
Failed to find rosdep libdc1394-dev for package videre_stereo_cam on OS:ubuntu version:10.04
WARNING: Rosdeps [u'libdc1394-dev'] could not be resolved
[ rosmake ] rosdep check passed all system dependencies in packages
[rosmake-0] Starting >>> rosbuild [ make ]                                                                
[rosmake-0] Finished <<< rosbuild ROS_NOBUILD in package rosbuild
 No Makefile in package rosbuild                                                                               
[rosmake-1] Starting >>> cpp_common [ make ]                                                                                                       
[rosmake-1] Finished <<< cpp_common ROS_NOBUILD in package cpp_common                                         
[rosmake-2] Starting >>> roslib [ make ]                                                                                                           
[rosmake-2] Finished <<< roslib ROS_NOBUILD in package roslib
[rosmake-3] Starting >>> xmlrpcpp [ make ]                                                          
[rosmake-0] Starting >>> roslang [ make ]                                                                                                 
[rosmake-1] Starting >>> roscpp_traits [ make ]
[rosmake-1] Finished <<< roscpp_traits ROS_NOBUILD in package roscpp_traits                                              
[rosmake-3] Finished <<< xmlrpcpp ROS_NOBUILD in package xmlrpcpp
[rosmake-2] Starting >>> rostime [ make ]                                                              
[rosmake-0] Finished <<< roslang ROS_NOBUILD in package roslang
 No Makefile in package roslang                                                                                  
[rosmake-2] Finished <<< rostime ROS_NOBUILD in package rostime                                                                                                      
[rosmake-3] Starting >>> std_msgs [ make ]
[rosmake-1] Starting >>> roscpp_serialization [ make ]                                       
[rosmake-0] Starting >>> rosconsole [ make ]                                                                                          
[rosmake-3] Finished <<< std_msgs ROS_NOBUILD in package std_msgs
[rosmake-0] Finished <<< rosconsole ROS_NOBUILD in package rosconsole                                                                 
[rosmake-1] Finished <<< roscpp_serialization ROS_NOBUILD in package roscpp_serialization                                                                                 
[rosmake-2] Starting >>> rosgraph_msgs [ make ]
[rosmake-2] Finished <<< rosgraph_msgs ROS_NOBUILD in package rosgraph_msgs                                              
[rosmake-3] Starting >>> opencv2 [ make ]                                                                                                                      
[rosmake-3] Finished <<< opencv2 ROS_NOBUILD in package opencv2
[rosmake-1] Starting >>> rosclean [ make ]                                                            
[rosmake-1] Finished <<< rosclean ROS_NOBUILD in package rosclean                                                                                                     
[rosmake-0] Starting >>> rosgraph [ make ]
[rosmake-2] Starting >>> roscpp [ make ]                                       
[rosmake-3] Starting >>> rospy [ make ]                                                                            
[rosmake-0] Finished <<< rosgraph ROS_NOBUILD in package rosgraph
[rosmake-2] Finished <<< roscpp ROS_NOBUILD in package roscpp                                                                
[rosmake-3] Finished <<< rospy ROS_NOBUILD in package rospy
[rosmake-1] Starting >>> rosmaster [ make ]                                                        
[rosmake-1] Finished <<< rosmaster ROS_NOBUILD in package rosmaster                                                                                                  
[rosmake-0] Starting >>> rosout [ make ]
[rosmake-0] Finished <<< rosout ROS_NOBUILD in package rosout                                       
[rosmake-2] Starting >>> rosunit [ make ]                                                                                                 
[rosmake-2] Finished <<< rosunit ROS_NOBUILD in package rosunit
[rosmake-3] Starting >>> yaml_cpp [ make ]                                                            
[rosmake-1] Starting >>> roslaunch [ make ]                                                                                                   
[rosmake-3] Finished <<< yaml_cpp ROS_NOBUILD in package yaml_cpp
[rosmake-1] Finished <<< roslaunch ROS_NOBUILD in package roslaunch
 No Makefile in package roslaunch                                                                            
[rosmake-0] Starting >>> tinyxml [ make ]                                                              
[rosmake-0] Finished <<< tinyxml ROS_NOBUILD in package tinyxml                                                                                                      
[rosmake-2] Starting >>> bond [ make ]
[rosmake-3] Starting >>> rostest [ make ]                                   
[rosmake-1] Starting >>> pluginlib [ make ]                                                                         
[rosmake-1] Finished <<< pluginlib ROS_NOBUILD in package pluginlib
[rosmake-3] Finished <<< rostest ROS_NOBUILD in package rostest                                                                  
[rosmake-2] Finished <<< bond ROS_NOBUILD in package bond
[rosmake-0] Starting >>> smclib [ make ]                                                      
[rosmake-1] Starting >>> topic_tools [ make ]                                                                                           
[rosmake-3] Starting >>> message_filters [ make ]
[rosmake-0] Finished <<< smclib ROS_NOBUILD in package smclib                                                
[rosmake-1 ...
(more)
edit retag flag offensive close merge delete

6 Answers

Sort by ยป oldest newest most voted
0

answered 2011-04-01 06:14:15 -0500

Michael Skolarikis gravatar image

updated 2011-04-01 06:15:40 -0500

Problem solved!!!

My Videre STOC camera sends image data as 2byte pixels in YUV422 format. For some reason, the camera reports that the frame it sends is in YUV411 format!

YUV422 bit size is set to 16, instead of YUV411 which is set to 12 in dc1394/utils.c. This was causing incomplete frames.

In libdc1394-2.1.2, at dc1394/control.c, line 672 I made the following change:

*mode= (uint32_t)((value >> 29) & 0x7UL) + DC1394_VIDEO_MODE_FORMAT0_MIN;

->

*mode= DC1394_VIDEO_MODE_640x480_YUV422;

Maybe there is a more elegant solution to this problem. The important thing for me is that I can finally get frames and point clouds!

Thank you very much Anton for your time!

edit flag offensive delete link more

Comments

That's pretty strange considering the driver explicitly sets the format to DC1394_VIDEO_MODE_640x480_YUV422 or DC1394_VIDEO_MODE_320x240_YUV422 depending on desired resolution (see line 269 in videre_stereo_node.cpp, and line 397 in videre_stereo_1394.cpp)... maybe something is not right there?
arebgun gravatar image arebgun  ( 2011-04-04 11:58:59 -0500 )edit
The code is exactly as you say, but the dcframe received from firewire has different mode. I'll try to track video mode, in libdc1394 and see where is the dcframe created and why it has wrong video mode. As you can see from the outputs above, video mode is 66 -> YUV411
Michael Skolarikis gravatar image Michael Skolarikis  ( 2011-04-06 11:33:37 -0500 )edit
At videre_stereo_1394.cpp , line 422 CHECK_ERR_CLEAN(dc1394_video_set_mode(dcCam, video), "Could not set video mode"); is not working for video = DC1394_VIDEO_MODE_640x480_YUV422. It does not report an error, but it sets the video_mode to DC1394_VIDEO_MODE_640x480_YUV411.
Michael Skolarikis gravatar image Michael Skolarikis  ( 2011-04-11 05:30:02 -0500 )edit

Michael I guess I'm having the same problem. Where can I find the files to modify, please?

ffusion gravatar image ffusion  ( 2012-11-12 22:59:58 -0500 )edit
1

answered 2011-03-23 12:34:58 -0500

arebgun gravatar image

updated 2011-03-29 05:48:23 -0500

Hi,

I am the maintainer of the videre_stereo_cam package. Unfortunately I did not have time to make a switch to ROS Diamondback yet, so this package (as available from svn) was not updated to work with that version yet. Here is a link to the patch that should be applied to current videre_stereo_cam version:

http://ubuntuone.com/p/k2J/

edit flag offensive delete link more
0

answered 2011-03-23 12:44:41 -0500

Michael Skolarikis gravatar image

Thank you very much for the immediate answer! I'll try the updated files in a few hours!

edit flag offensive delete link more

Comments

BTW you can use the comment feature to comment on answers.
tfoote gravatar image tfoote  ( 2011-03-23 13:02:14 -0500 )edit
0

answered 2011-03-24 00:58:19 -0500

Michael Skolarikis gravatar image

updated 2011-03-24 01:07:26 -0500

Unfortunately the problem remains...

This is the debug window, when i run the SVS program

SVS Debugging Window

Pixel depth: 24
[dSystem] 1 card(s) found, 2 node(s)
[dSystem] Finding cameras on the bus
Kernel 2.6
Bus map is 4 quadlets
Node count is 2
Root: 1; host: 1 IRM: 1
Checking card 0, node 0
Chip id: 550504 83177
CCR addr: f0f00000
Vendor name: VIDERE_DESIGN
Model name: MDS-STH
Checking card 0, node 1
[Reset] 1 cameras on the bus
SVS version 4.4f -- DCS Digital Stereo Interface
MMX presence: 7
1 devices found:
   VIDERE_DESIGN MDS-STH #0055050400083177
[Open] IEEE 1394 system initialized
[Open] Found 1 cameras
[Open] Checking device 0 name VIDERE_DESIGN MDS-STH #0055050400083177
[Open] using stereo dev 0 name VIDERE_DESIGN MDS-STH #0055050400083177
[InitCamera] Video formats: 80000000
[InitCamera] Video mode 0: 10000000
[InitCamera] Video mode 1: 00000000
[InitCamera] Video mode 2: 00000000
Setting iso channel (0) and speed (2)
[InitCamera] Camera ISO speed set to 400 Mb/sec
[InitCamera] Speed val: 2000000
[InitCamera] Opened device /dev/video1394
[SetCam] Basic functions: 00008000
[SetCam] Feat high/low: D2800000/00000000
[SetCam] Max exposure: 0x211
[SetCam] Max gain: 0x30
[SetCam] Max brightness: 0xFF
[SetCam] Max whitebalance: 0x1E
[SetCam] MDCS type, using Bayer pattern for color
[SetCam] FW firmware word: 00000602
[SetCam] Reading local parameters
[SetCam] FW firmware: 0602
[SetCam] Camera firmware: 6 : 01080406
[SetCam] STOC firmware: 00040204
[SetCam] Image inverted: 0
[SetCam] No black offset parameter
[SetCam] No Y offset parameter
[SetCam] Camera imager max size: 640 x 480
[SetCam] Camera frame div: 1 (max), 1
[SetCam] Camera 50 Hz rate available, set to 1
[SetCam] STOC firmware word: 00040204
[SetCam] On-chip processing available, default 0 (off - no output)
[SetCam] Badpix value: ffffffff
[Open] Device initialized
[Open] MT9V022 Imager
[Open] Stereo processing on camera, mode 3
[Open] Color capable
[Open] Color type is RGGB
[Open] Using FAST color interpolation
[GetCalib] FW firmware:  00000602
Calibration start: 0x23205356
Read 1976 bytes
[Open] Read in calibration from device
[Open] Conf: 12  Uniq: 10
[SetProcMode] Conf: 12  Uniq: 10
Opened device 0
[SetProcMode] Conf: 12  Uniq: 10
[User] Proc mode disparity
[CheckParams] Enter: 640x480, fdiv 1, dec 1, bin 1
[CheckParams] Exit:  640x480, fdiv 1, dec 1, bin 1
[SetProcMode] Conf: 12  Uniq: 10
[User] Proc mode disparity
[CheckParams] Enter: 640x480, fdiv 1, dec 1, bin 1
[CheckParams] Exit:  640x480, fdiv 1, dec 1, bin 1
[SetSize] Input size 640x480, fdiv 1
[SetSize] Speed is 30 fps
[Start] Format: 0  Mode: 3  Speed: 4
Starting DMA
w, h: 640, 480
frame bytes: 614400
Size: 614400
Using ISO channel 0
buf size: 614400
Setting iso channel (0) and speed (2)
Speed val: 02000000
[Stop] Stopping DMA
edit flag offensive delete link more

Comments

So it's exactly the same problem, it fails in the same place? I will need to look at it again, test it with diamondback and videre cameras I have available... I might be able to do it early next week.
arebgun gravatar image arebgun  ( 2011-03-25 06:04:39 -0500 )edit
0

answered 2011-03-25 11:04:57 -0500

Michael Skolarikis gravatar image

Yes, it's exactly the same problem. Something goes wrong in deinterlacing. I'll look at it again in a couple of days and try to be more specific. Tell me if you need some extra information. Thank you for your time!

edit flag offensive delete link more

Comments

Hi, I just updated my original answer with a link to the new patch. I tested it with my Videre STOC camera and it works just fine. Let me know if it works for you.
arebgun gravatar image arebgun  ( 2011-03-29 05:49:22 -0500 )edit
What is wrong?
arebgun gravatar image arebgun  ( 2011-03-31 05:46:23 -0500 )edit
0

answered 2011-03-31 05:47:43 -0500

Michael Skolarikis gravatar image

updated 2011-03-31 10:32:33 -0500

The code still won't run.

The good news are that I figured out what's wrong.

For some reason, the frame being captured has smaller size than it should. The bottom part(almost 1/3) of the frames is not returned.

When deinterlacing takes place, the function assumes that it has to deal with 640*480 images. At some point, unallocated memory is being parsed and segfault occurs.

I found a file named "videre_fix.patch", which patches dc1394/control.c and dc1394/control.h and I was told that is supposed to fix that problem. Patched, configure, make, make install libdc1394-2.1.2 but still no luck.

Are there any suggestions to this problem?

Anton, thank you very much for your time!

videre_fix.patch

Index: dc1394/control.c
===================================================================
--- dc1394/control.c    (revision 563)
+++ dc1394/control.c    (working copy)
@@ -1038,6 +1038,20 @@
 }

 dc1394error_t
+dc1394_feature_whitebalance_set_value_blind(dc1394camera_t *camera, uint32_t u_b_value, uint32_t v_r_value)
+{
+    uint32_t curval;
+    dc1394error_t err;
+    //    err=dc1394_get_control_register(camera, REG_CAMERA_WHITE_BALANCE, &curval);
+    //    DC1394_ERR_RTN(err, "Could not get white balance");
+
+    curval= ( ((u_b_value & 0xFFFUL) << 12) | (v_r_value & 0xFFFUL) );
+    err=dc1394_set_control_register(camera, REG_CAMERA_WHITE_BALANCE, curval);
+    DC1394_ERR_RTN(err, "Could not set white balance");
+    return err;
+}
+
+dc1394error_t
 dc1394_feature_temperature_get_value(dc1394camera_t *camera, uint32_t *target_temperature, uint32_t *temperature)
 {
     uint32_t value;
@@ -1248,6 +1262,33 @@
 }

 dc1394error_t
+dc1394_feature_set_value_blind(dc1394camera_t *camera, dc1394feature_t feature, uint32_t value)
+{
+    uint32_t quadval;
+    uint64_t offset;
+    dc1394error_t err;
+
+    if ( (feature<DC1394_FEATURE_MIN) || (feature>DC1394_FEATURE_MAX) )
+        return DC1394_INVALID_FEATURE;
+
+    if ((feature==DC1394_FEATURE_WHITE_BALANCE)||
+        (feature==DC1394_FEATURE_WHITE_SHADING)||
+        (feature==DC1394_FEATURE_TEMPERATURE)) {
+        err=DC1394_INVALID_FEATURE;
+        DC1394_ERR_RTN(err, "You should use the specific functions to write from multiple-value features");
+    }
+
+    FEATURE_TO_VALUE_OFFSET(feature, offset);
+
+    //    err=dc1394_get_control_register(camera, offset, &quadval);
+    //    DC1394_ERR_RTN(err, "Could not get feature value");
+
+    err=dc1394_set_control_register(camera, offset, (value & 0xFFFUL));
+    DC1394_ERR_RTN(err, "Could not set feature value");
+    return err;
+}
+
+dc1394error_t
 dc1394_feature_is_present(dc1394camera_t *camera, dc1394feature_t feature, dc1394bool_t *value)
 {
 /*
@@ -1536,6 +1577,44 @@
 }

 dc1394error_t
+dc1394_feature_set_mode_blind(dc1394camera_t *camera, dc1394feature_t feature, dc1394feature_mode_t mode)
+{
+    dc1394error_t err;
+    uint64_t offset;
+    uint32_t value;
+
+    if ( (feature<DC1394_FEATURE_MIN) || (feature>DC1394_FEATURE_MAX) )
+        return DC1394_INVALID_FEATURE;
+
+    if ( (mode<DC1394_FEATURE_MODE_MIN) || (mode>DC1394_FEATURE_MODE_MAX) )
+        return DC1394_INVALID_FEATURE_MODE;
+
+    if (feature == DC1394_FEATURE_TRIGGER) {
+        return DC1394_INVALID_FEATURE;
+    }
+
+    FEATURE_TO_VALUE_OFFSET(feature, offset);
+
+    //    err=dc1394_get_control_register(camera, offset, &curval);
+    //    DC1394_ERR_RTN(err, "Could not get feature register");
+
+    if (mode==DC1394_FEATURE_MODE_AUTO)
+    {
+      value = 0x01000000UL;
+      err=dc1394_set_control_register(camera, offset, value);
+      DC1394_ERR_RTN(err, "Could not set auto mode for feature");
+    }
+    else if (mode==DC1394_FEATURE_MODE_MANUAL)
+    {
+      value = 0;
+      err=dc1394_set_control_register(camera, offset, value);
+      DC1394_ERR_RTN(err, "Could not set auto mode for feature");
+    }
+
+    return err;
+}
+
+dc1394error_t
 dc1394_feature_get_boundaries(dc1394camera_t *camera, dc1394feature_t feature, uint32_t *min, uint32_t *max)
 {
     dc1394error_t err;
Index: dc1394/control.h
===================================================================
--- dc1394/control.h    (revision 563)
+++ dc1394/control.h    (working copy)
@@ -234,6 +234,11 @@
 dc1394error_t dc1394_feature_whitebalance_set_value(dc1394camera_t *camera, uint32_t u_b_value, uint32_t v_r_value);

 /**
+ * Sets the whitebalance values without checking the current values
+ */
+dc1394error_t dc1394_feature_whitebalance_set_value_blind(dc1394camera_t *camera, uint32_t u_b_value, uint32_t v_r_value);
+
+/**
  * Gets the temperature values (target and current)
  */
 dc1394error_t dc1394_feature_temperature_get_value(dc1394camera_t *camera, uint32_t *target_temperature, uint32_t *temperature);
@@ -264,6 +269,11 @@
 dc1394error_t dc1394_feature_set_value(dc1394camera_t *camera, dc1394feature_t feature, uint32_t value);

 /**
+ * Sets the value of a feature without checking the current value
+ */
+dc1394error_t dc1394_feature_set_value_blind(dc1394camera_t *camera, dc1394feature_t feature, uint32_t value);
+
+/**
  * Tells whether a feature is present or not
  */
 dc1394error_t dc1394_feature_is_present(dc1394camera_t *camera, dc1394feature_t feature, dc1394bool_t *value);
@@ -309,6 +319,11 @@
 dc1394error_t dc1394_feature_set_mode(dc1394camera_t *camera ...
(more)
edit flag offensive delete link more

Comments

You don't need to patch dc1394, whatever comes with the Ubuntu should work just fine. These modified functions that Videre cameras need are already in the package. So whatever frame come from camera is smaller than 640*480? Does camera work with SVS software that is provided by Videre?
arebgun gravatar image arebgun  ( 2011-03-31 10:43:58 -0500 )edit
Yes! SVS works fine, which means that the camera is not damaged. A student in my university had exactly the same problem some years ago. He asked for help from videre and they sent him this patch. Unfortunately, I could not contact him and learn more details. The frames I get are 640*360
Michael Skolarikis gravatar image Michael Skolarikis  ( 2011-03-31 11:04:04 -0500 )edit
Could you check if the camera is working with camera1394 package? It will look a little weird, but at least we'll see if that gets us a full 640*480 image.
arebgun gravatar image arebgun  ( 2011-03-31 11:38:37 -0500 )edit

Question Tools

Stats

Asked: 2011-03-23 11:17:04 -0500

Seen: 956 times

Last updated: Apr 01 '11