Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small typo breaking code in stereo calibration #84

Closed
pieleric opened this issue Jun 29, 2014 · 4 comments
Closed

Small typo breaking code in stereo calibration #84

pieleric opened this issue Jun 29, 2014 · 4 comments

Comments

@pieleric
Copy link

Hi,
It was probably introduced during the convertion to opencv2. When running stereo calibration with git head (indigo), I got this:

Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/home/xinwang/catkin_ws/src/image_pipeline/camera_calibration/nodes/cameracalibrator.py", line 68, in run
    self.function(m)
  File "/home/xinwang/catkin_ws/src/image_pipeline/camera_calibration/nodes/cameracalibrator.py", line 151, in handle_stereo
    self.redraw_stereo(drawable)
  File "/home/xinwang/catkin_ws/src/image_pipeline/camera_calibration/nodes/cameracalibrator.py", line 299, in redraw_stereo
    display[0:height, 0:width,:] = drawable.lscrib
ValueError: could not broadcast input array from shape (240,320,3) into shape (240,240,3)

The fix is pretty obvious:

--- a/camera_calibration/nodes/cameracalibrator.py
+++ b/camera_calibration/nodes/cameracalibrator.py
@@ -293,7 +293,7 @@ class OpenCVCalibrationNode(CalibrationNode):

     def redraw_stereo(self, drawable):
         height = drawable.lscrib.shape[0]
-        width = drawable.lscrib.shape[0]
+        width = drawable.lscrib.shape[1]

         display = numpy.zeros((max(480, height), 2 * width + 100, 3), dtype=numpy.uint8)
         display[0:height, 0:width,:] = drawable.lscrib
@vrabaud
Copy link
Contributor

vrabaud commented Jun 29, 2014

thx !, don't hesitate to make a PR for the following times.

@IN-Gamut
Copy link

IN-Gamut commented Sep 1, 2015

Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/home/johnny/Desktop/MyWorkspace/src/image_pipeline/camera_calibration/nodes/cameracalibrator.py", line 93, in run
self.function(self.queue[0])
File "/home/johnny/Desktop/MyWorkspace/src/image_pipeline/camera_calibration/nodes/cameracalibrator.py", line 182, in handle_stereo
self.redraw_stereo(drawable)
File "/home/johnny/Desktop/MyWorkspace/src/image_pipeline/camera_calibration/nodes/cameracalibrator.py", line 325, in redraw_stereo
display[0:height, width:2*width,:] = drawable.rscrib
ValueError: could not broadcast input array from shape (480,640,3) into shape (415,739,3)

@vrabaud
Copy link
Contributor

vrabaud commented Sep 1, 2015

@LIN-Xiangru , it seems your two cameras do not have the same size. Do you have a small rosbag I could test with ?

@IN-Gamut
Copy link

IN-Gamut commented Sep 1, 2015

yes I use two different cameras one is RGB and the other is IR, I want to calibrate them both. Is it possible for me to do that ? RGB resobution ( 1280 x 720) IR resolution ( 640 x 480 )

One way to do that is

    if scale > 1.0:
        # scrib = cv2.resize(img, (int(width / scale), int(height / scale)))
        scrib = cv2.resize(img, (640,480))

Is it better to change the int(width / scale) to another value, because for 1280 x 720, int(width / scale) will not be 640, it is 739 instead. There is a rounding issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants