How can I use time as my file name and have the save function in a class

asked 2017-05-05 14:29:28 -0500

Sinjon gravatar image

Hello,

I'm trying to use time as my filename header but can't time to get it functioning. and then also want it in class but I couldn't get that working.

This is my current code to get it

fourcc = cv2.VideoWriter_fourcc(*args["codec"])
writer = None
(h, w) = (None, None)
zeros = None

if writer is None:
        (h, w) = frame.shape[:2]     
        writer = cv2.VideoWriter(args["output"], fourcc, args["fps"],
            (w * 1, h * 1), True)
        zeros = np.zeros((h, w), dtype="uint8") 
        output = np.zeros((h * 1, w * 1, 3), dtype="uint8")
        output[0:h, 0:w] = frame
 write.write(output)


def show_time ():
    rightNow = datetime.datetime.now()
    currentTime = ("tracker:%04d%02d%02d_%02d:%02d:%02d.avi" %                                    ( rightNow.year, rightNow.month, rightNow.day, rightNow.hour, rightNow.minute, rightNow.second ))
    return currentTime
args["ouput"] = show_time()

tried using

now = datetime.datetime.now()
writer = cv2.VideoWriter(now".avi", fourcc, args["fps"],

then for saving using a class, I used the following code when writing a file was working. I tried putting the variables in the brackets but it didn't agree with (h, w). I'm also not too sure how to call the function.

def save ():
        (h, w) = frame.shape[:2]
        writer = cv2.VideoWriter(args["output"], fourcc, args["fps"],
            (w * 2, h * 1), True)
        zeros = np.zeros((h, w), dtype="uint8") 
        output = np.zeros((h * 1, w * 1, 3), dtype="uint8")
        output = np.zeros((h * 1, w * 1, 3), dtype="uint8")
       output[0:h, 0:w] = frame 
       return = output 

if writer is None
    output = save()
    writer.write(output)

Thanks in advance!

edit retag flag offensive close merge delete

Comments

throwing it all away, and starting from scratch might be the best idea here, it's all broken beyond repair.

focus on how to open a VideoWriter correctly first, then try with the date string.

berak gravatar imageberak ( 2017-05-06 07:21:40 -0500 )edit