I am working on the following problem. Lets say I have data (say image values RGB as integers) in a file per line. I want to read 10000 of these lines and make a frame object (image frame containing 10000 RGB Values) and send it to downstream function in the processing pipeline. Then read the next 10000 lines and make another frame object and send it to downstream function in the pipeline.
How can i setup this function that it keeps on making frame objects until the end of file is reached. Is the following the right way to do it? Are there other neat approaches?
class frame_object(object):
def __init__(self):
self.line_cnt = 0
self.buffer = []
def make_frame(line):
if(self.line_cnt < 9999):
self.buffer.append(line)
return self.buffer