0

I get an attribute error if I use the function:

def faceDetection():
   if results.detections:
      for detection in results.detection:
         print(id, detection)

AttributeError: type object 'SolutionOutputs' has no attribute 'detections'

is the error I get if I try running, specifically it calls it on the results.detections: line it works fine in this youtube tutorial at 1:43:56 I don't really know how to read the github code but here's the link I do have

mpFD = mp.solutions.face_detection # FD = face_detection
fD = mpFD.FaceDetection()

defined before the function already. Is this an issue with my code or is it something else?

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
  • See what the 'results' object does have by inspecting it with something like the vars function: https://stackoverflow.com/questions/192109/is-there-a-built-in-function-to-print-all-the-current-properties-and-values-of-a – ryanwebjackson Oct 21 '22 at 03:54

2 Answers2

0

This error depends on the Python version you are using. You need to use the version minimum Python 3.9 but most probably you are using Python 3.6.

It would be better to create an environment with conda by specifying Python version and install mediapipe in there and try to run your code again. The error will disappear.

Here is an example how to establish environment to run mediapipe examples.

Yunus Temurlenk
  • 4,085
  • 4
  • 18
  • 39
0

It wasn't a problem with the mediapipe library, but I hadn't initialized results as the faceDetections solutions, but I had results as a value for the hands solution module.