Oct-14-2022, 09:10 AM
(This post was last modified: Oct-14-2022, 10:16 AM by Yoriz.
Edit Reason: Added error tags
)
Hello,
I'm a beginner in python and I'm trying to get the beginning (picture_nr_hanger_start) and the end (picture_nr_hanger_end) of equal sequences of the list "hash_list_film".
The list "hash_list_film" is filled with numbers (later the numbers will be replaced with hash strings):
hash_list_film = ["12", "11", "11", "11", "17", "22", "22", "22", "22", "23"]
What I'm trying to achieve is to detect equal numbers (film hangers) in hash_list_film.
Therefore later I'm planning to extract the pictures of a film and examine them with a perceptual hash - picture_nr_hanger_start and picture_nr_hanger_end shall be returned.
Hanging position is: 1 to 3 and 5 to 8.
My problem is:
What I'm doing wrong with hash_list_film in line 29?
Could you please tell me what I'm doing wrong within the code?
For any help I will be very thankful!!
Greetings, flash77
I'm a beginner in python and I'm trying to get the beginning (picture_nr_hanger_start) and the end (picture_nr_hanger_end) of equal sequences of the list "hash_list_film".
The list "hash_list_film" is filled with numbers (later the numbers will be replaced with hash strings):
hash_list_film = ["12", "11", "11", "11", "17", "22", "22", "22", "22", "23"]
What I'm trying to achieve is to detect equal numbers (film hangers) in hash_list_film.
Therefore later I'm planning to extract the pictures of a film and examine them with a perceptual hash - picture_nr_hanger_start and picture_nr_hanger_end shall be returned.
Hanging position is: 1 to 3 and 5 to 8.
My problem is:
What I'm doing wrong with hash_list_film in line 29?
Could you please tell me what I'm doing wrong within the code?
For any help I will be very thankful!!
Greetings, flash77
Error:Traceback (most recent call last):
File "D:\python-Programmierung\BildNr_to_Zeit\main.py", line 29, in <module>
picture_nr_hanger_start, picture_nr_hanger_end = HangerFinder.detect_picture_nr(start_examine, hash_list_film)
TypeError: HangerFinder.detect_picture_nr() missing 1 required positional argument: 'hash_list_film'
class HangerFinder: def __init__(self, start_examine, hash_list_film, end_of_list, picture_nr_hanger_start, picture_nr_hanger_end): self.start_examine = start_examine self.hash_list_film = hash_list_film self.end_of_list = end_of_list self.picture_nr_hanger_start = picture_nr_hanger_start self.picture_nr_hanger_end = picture_nr_hanger_end def detect_picture_nr(self, start_examine, hash_list_film): end_of_list = len(hash_list_film) - 1 for i in range(start_examine, end_of_list): # detects picture_nr, start hanger if i + 1 > end_of_list: break else: if hash_list_film[i + 1] == hash_list_film[i]: picture_nr_hanger_start = i for j in range(i, end_of_list): if hash_list_film[j + 1] != hash_list_film[j]: picture_nr_hanger_end = j start_examine = j + 1 return picture_nr_hanger_start, picture_nr_hanger_end hash_list_film = ["12", "11", "11", "11", "17", "22", "22", "22", "22", "23"] start_examine = 0 print(hash_list_film) picture_nr_hanger_start, picture_nr_hanger_end = HangerFinder.detect_picture_nr(start_examine, hash_list_film)