Operands to the || and && operators must be convertible to logical scalar values

1 view (last 30 days)
I am using the stereo calibrator app to calibrate my camera I am using 10 pair of images from my stereo cam setup and giving them as an input in the app. It is generating the stereoParams object which has all the intrinsic and extrinsic matrices that are required, but also at the same time it is also saying a warning in the command prompt
Warning: JPEG library error (8 bit), "Premature end of JPEG file"."
And when i am trying to rectify a image from the stereo cam using the following code:
[J1, J2] = rectifyStereoImages(I1, I2, stereoParams);
It is showing the following error
Operands to the and && operators must be convertible to logical scalar values
Error in vision.internal.calibration.CameraParametersImpl/getValidBounds (line 883)
if isempty(coder.target) && (left > right || top > bot)
Error in vision.internal.calibration.CameraParametersImpl/computeUndistortBounds
(line 785)
[xBounds, yBounds] = getValidBounds(this, undistortedMask, ...
Error in vision.internal.calibration.StereoParametersImpl/computeOutputBounds (line 371)
[xBoundsUndistort1, yBoundsUndistort1] = ...
Error in
vision.internal.calibration.StereoParametersImpl/computeRectificationParameters
(line 271)
[xBounds, yBounds] = computeOutputBounds(this, imageSize, ...
Error in vision.internal.calibration.StereoParametersImpl/rectifyStereoImagesImpl
(line 190)
[H1, H2, Q, xBounds, yBounds] = ...
Error in rectifyStereoImages (line 99)
rectifiedImage1, rectifiedImage2] = rectifyStereoImagesImpl(stereoParams, ...
How do i remove both the the warning and the error???
  2 Comments
Walter Roberson
Walter Roberson on 20 Jul 2015
The warning about premature end of JPEG: at what point is that occurring?
What is size(stereoParams) and class(stereoParams) as well?
Newman
Newman on 21 Jul 2015
@Walter Roberson The warning is occurring at the time when i am pressing the add images button in the stereo calibrator app.I mean after it has detected the checker board corners.An the warning is repeating itself three/four times kindly look at the screen shot *stereoparams
<<
>>
  • is the object that contains all the parameter extrinsic and intrinsic.it is created when u click on export camera parameters button

Sign in to comment.

Accepted Answer

Dima Lisin
Dima Lisin on 20 Jul 2015
Hi Antariksha,
The warning you are getting may indicate a corrupt image file. By the way, when you capture your calibration images, please save them in a format that uses lossless compression, like PNG or BMP. JPEG's compression is lossy, which introduces artifacts into the image, which affect calibration accuracy.
The error you are getting from rectifyStereoImages indicates that the function cannot compute the size of the output image. This indicates a problem with your calibration. Try the following:
J = undistortImage(I1, stereoParams.CameraParameters1, 'OutputView', 'full');
imshow(J);
I expect that you will see a very strange image, kind of folded upon itself.
If you used 3 radial distortion coefficients for your calibration, try re-calibrating using only 2. Also, try capturing more calibration images with the checkerboard closer to the edges and corners of the frame. Also, make sure that the checkerboard is in various 3D orientations, tilted and slanted in different ways.

More Answers (1)

the cyclist
the cyclist on 20 Jul 2015
I am guessing that in the line
if isempty(coder.target) && (left > right || top > bot)
that one or more of those variables are vectors or matrices. The && and operators can only be used when the arguments (e.g. "left > right") evaluate to a scalar -- a single value, not a vector. The reason is that these "short-circuit" operators need a single condition to evaluate, not a vector of conditions.
  2 Comments
Newman
Newman on 20 Jul 2015
@the cyclist this is an inbuilt function so what shud i do to rectify this error?
the cyclist
the cyclist on 20 Jul 2015
I have to admit that that is a mystery to me. Are you calling the function with the correct data type inputs?
Perhaps you could use debug mode to go inside the function and see more specifically where this goes wrong.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!