diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp
index f1f2113446..4697a01057 100644
--- a/modules/objdetect/src/hog.cpp
+++ b/modules/objdetect/src/hog.cpp
@@ -1459,6 +1459,7 @@ void HOGDescriptor::detect(const Mat& img,
     Size winStride, Size padding, const std::vector<Point>& locations) const
 {
     hits.clear();
+    weights.clear();
     if( svmDetector.empty() )
         return;
 
diff --git a/modules/videoio/src/cap_ximea.cpp b/modules/videoio/src/cap_ximea.cpp
index ccf49e45b5..b876995f0c 100644
--- a/modules/videoio/src/cap_ximea.cpp
+++ b/modules/videoio/src/cap_ximea.cpp
@@ -221,7 +221,7 @@ void CvCaptureCAM_XIMEA::resetCvImage()
     xiGetParamInt( hmv, XI_PRM_HEIGHT, &height);
     xiGetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, &format);
 
-    if( (int)image.width != width || (int)image.height != height || image.frm != (XI_IMG_FORMAT)format)
+    if( (int)image.width != frame->width || (int)image.height != frame->height || image.frm != (XI_IMG_FORMAT)format)
     {
         if(frame) cvReleaseImage(&frame);
         frame = NULL;