title: python opencv findContours() error cpp 197
body: <p>Trying to use findContours() but keep getting a cpp:197 error (-210:Unsupported format or combination of formats)</p>
  <p>I have used the same format in other files and it works fine. Not sure why it doesn't work here.</p>
  <p>full error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:/Users/FreddyMac/PycharmProjects/TestProj/ballTrackingAbsDiff.py&quot;, line 33, in &lt;module&gt;
      cnts = cv2.findContours(th1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
  cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-cff9bdsm\opencv\modules\imgproc\src\contours.cpp:197: error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in function 'cvStartFindContours_Impl'
  </code></pre>
  <p>I checked the type of my image and is the correct 'uint8' type.</p>
  <p>see code below.</p>
  <pre><code>import cv2
  import imutils
  
  vs = cv2.VideoCapture('ballsFlying.MP4')
  while True:
      # read frame1, resize and convert to grayscale
      ret, frame1 = vs.read()
      if frame1 is None:
          break
      frame1 = imutils.resize(frame1, width=600)
      gray1 = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)
  
      # read frame2, resize and convert to grayscale
      ret2, frame2 = vs.read()
      if frame2 is None:
          break
      frame2 = imutils.resize(frame2, width=600)
      gray2 = cv2.cvtColor(frame2, cv2.COLOR_BGR2GRAY)
  
      # compute the difference between frames
      dist = cv2.absdiff(frame1, frame2)
      # blur image
      blurred = cv2.GaussianBlur(dist, (9, 9), 0)
  
      # global thresholding
      ret3, th1 = cv2.threshold(blurred, 85, 255, cv2.THRESH_BINARY)
      print(th1.dtype)
  
      cnts = cv2.findContours(th1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
  
      # other way to find contours = same error
      # hierarchy, contours = cv2.findContours(th1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
  
      cv2.imshow('dist', frame1)
      cv2.imshow('thresh', th1)
      cv2.imshow('blurred', blurred)
  
      # show the frame to our screen
      key = cv2.waitKey(100) &amp; 0xFF
      # if the 'q' key is pressed, stop the loop
      if key == ord(&quot;q&quot;):
          break
  
  # otherwise, release the camera
  vs.release()
  # close all windows
  cv2.destroyAllWindows()
  
  </code></pre>