oliveox / digikam-object-detection-plugin

DigiKam media files search by contained objects
9 stars 1 forks source link

TypeError: 'str' object cannot be interpreted as an integer #9

Open rickysarraf opened 1 year ago

rickysarraf commented 1 year ago

Got the below error during object detection.

Inserted [/home/rrs/rrs-home/Data/Pictures/.Digikam_Managed/Anshika/IMG_20190415_145725.jpg] in database!"
Objects: [person]
################################
Error while analysing filepath: [/home/rrs/rrs-home/Data/Pictures/.Digikam_Managed/Anshika/VID20190406135117.mp4]. Exception: ['str' object cannot be interpreted as an integer]
Traceback (most recent call last):
  File "/home/rrs/digikam-object-detection-plugin/src/services/utils.py", line 56, in analyze_entities
    objects = ObjectDetector.get_objects_in_file(model, file_path)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rrs/digikam-object-detection-plugin/src/services/object_detection.py", line 32, in get_objects_in_file
    for fno in range(0, total_frames, VIDEO_FRAME_STEP):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'str' object cannot be interpreted as an integer
################################
Error while analysing filepath: [/home/rrs/rrs-home/Data/Pictures/.Digikam_Managed/Anshika/VID20190510145046.mp4]. Exception: ['str' object cannot be interpreted as an integer]
Traceback (most recent call last):
  File "/home/rrs/digikam-object-detection-plugin/src/services/utils.py", line 56, in analyze_entities
    objects = ObjectDetector.get_objects_in_file(model, file_path)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rrs/digikam-object-detection-plugin/src/services/object_detection.py", line 32, in get_objects_in_file
    for fno in range(0, total_frames, VIDEO_FRAME_STEP):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'str' object cannot be interpreted as an integer
################################
################################
Inserted [/home/rrs/rrs-home/Data/Pictures/.Digikam_Managed/Anshika/IMG_7514.jpg] in database!"
Objects: [teddy bear, person]

This happens for type video files.

rickysarraf commented 1 year ago
commit 64aeef7a908f76441712782420957d303b211330 (HEAD -> master)
Author: Ritesh Raj Sarraf <rrs@debian.org>
Date:   Thu Mar 23 20:45:59 2023 +0530

    Mark VIDEO_FRAME_STEP as type integer

diff --git a/src/services/object_detection.py b/src/services/object_detection.py
index ed77f54..6f3b43e 100644
--- a/src/services/object_detection.py
+++ b/src/services/object_detection.py
@@ -29,7 +29,7 @@ class ObjectDetector:

             objects = []
             # sample_rate = total_frames / 1
-            for fno in range(0, total_frames, VIDEO_FRAME_STEP):
+            for fno in range(0, total_frames, int(VIDEO_FRAME_STEP)):
                 cap.set(cv2.CAP_PROP_POS_FRAMES, fno)
                 _, image = cap.read()