this is my code until the error occured :
import cv2
import numpy as np
import glob
import random
print(cv2.__version__)
# Load Yolo
net = cv2.dnn.readNet(r"C:\HALCON\PROJECTS\YOLO\yolo_custom_detection\yolov3_training_last.weights", r"C:\HALCON\PROJECTS\YOLO\yolo_custom_detection\yolov3_testing.cfg")
# Name custom object
classes = ["handle"]
# Images path
images_path = glob.glob(r"C:\HALCON\PROJECTS\YOLO\RightHandle1_images_YOLO\*.jpg")
layer_names = net.getLayerNames()
print(layer_names)
output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()]
my error :
Traceback (most recent call last):
File "c:\HALCON\PROJECTS\YOLO\yolo_custom_detection\yolo_object_detection.py", line 20, in <module>
output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()]
File "c:\HALCON\PROJECTS\YOLO\yolo_custom_detection\yolo_object_detection.py", line 20, in <listcomp>
output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()]
IndexError: invalid index to scalar variable.