Merge pull request #18526 from alalek:fix_uninitialized_warnings

pull/18532/head
Alexander Alekhin 4 years ago
commit 62b5d37b6b
  1. 41
      modules/videoio/src/cap_dc1394_v2.cpp

@ -221,60 +221,57 @@ bool CvCaptureCAM_DC1394_v2_CPP::startCapture()
DC1394_ISO_SPEED_3200); DC1394_ISO_SPEED_3200);
} }
// should a specific mode be used dc1394video_modes_t videoModes;
if (userMode >= 0) dc1394_video_get_supported_modes(dcCam, &videoModes);
// should a specific mode be used
while (userMode >= 0) // 'if' semantic, no real loop here
{ {
dc1394video_mode_t wantedMode; dc1394video_mode_t wantedMode;
dc1394video_modes_t videoModes;
dc1394_video_get_supported_modes(dcCam, &videoModes);
//set mode from number, for example the second supported mode, i.e userMode = 1
if (userMode < (int)videoModes.num) if (userMode < (int)videoModes.num)
{ {
// set mode from number, for example the second supported mode, i.e userMode = 1
wantedMode = videoModes.modes[userMode]; wantedMode = videoModes.modes[userMode];
} }
else if ((userMode >= DC1394_VIDEO_MODE_MIN) && (userMode <= DC1394_VIDEO_MODE_MAX))
//set modes directly from DC134 constants (from dc1394video_mode_t)
else if ((userMode >= DC1394_VIDEO_MODE_MIN) && (userMode <= DC1394_VIDEO_MODE_MAX ))
{ {
// set modes directly from DC134 constants (from dc1394video_mode_t)
//search for wanted mode, to check if camera supports it //search for wanted mode, to check if camera supports it
int j = 0; int j = 0;
while ((j< (int)videoModes.num) && videoModes.modes[j]!=userMode) while ((j < (int)videoModes.num) && videoModes.modes[j] != userMode)
{ {
j++; j++;
} }
if (!(j < (int)videoModes.num))
if ((int)videoModes.modes[j]==userMode)
{
wantedMode = videoModes.modes[j];
}
else
{ {
userMode = -1; // wanted mode not supported, search for best mode userMode = -1; // wanted mode not supported, search for best mode
break;
} }
wantedMode = videoModes.modes[j];
} }
else else
{ {
userMode = -1; // wanted mode not supported, search for best mode userMode = -1; // wanted mode not supported, search for best mode
break;
} }
//if userMode is available: set it and update size //if userMode is available: set it and update size
if (userMode != -1)
{ {
code = dc1394_video_set_mode(dcCam, wantedMode); code = dc1394_video_set_mode(dcCam, wantedMode);
uint32_t width, height; uint32_t width = 0, height = 0;
dc1394_get_image_size_from_video_mode(dcCam, wantedMode, &width, &height); dc1394_get_image_size_from_video_mode(dcCam, wantedMode, &width, &height);
frameWidth = (int)width; frameWidth = (int)width;
frameHeight = (int)height; frameHeight = (int)height;
} }
break;
} }
if (userMode == -1 && (frameWidth > 0 || frameHeight > 0)) if (userMode == -1 && (frameWidth > 0 || frameHeight > 0))
{ {
dc1394video_mode_t bestMode = (dc1394video_mode_t) - 1; dc1394video_mode_t bestMode = (dc1394video_mode_t)(-1);
dc1394video_modes_t videoModes;
dc1394_video_get_supported_modes(dcCam, &videoModes);
for (i = 0; i < (int)videoModes.num; i++) for (i = 0; i < (int)videoModes.num; i++)
{ {
dc1394video_mode_t mode = videoModes.modes[i]; dc1394video_mode_t mode = videoModes.modes[i];

Loading…
Cancel
Save