Create a hue transform video of an RGB video

asked 2018-05-14 05:12:10 -0500

I want to create a video that's the hue transformation and then convert it to a binary image using thresholding. I give an RGB video as input and want to write it's hue transformation. Can someone help me? This is the code I have written (process_img does the transformation).

cap = cv2.VideoCapture(file_path)
fourcc = cv2.VideoWriter_fourcc('M','J','P','G')
out = cv2.VideoWriter(vid_out,fourcc, 30, (640,480))

while(cap.isOpened()):
    ret, frame = cap.read()
    if ret==True:
        result = process_img(frame)

        # write the flipped frame
        out.write(result)
        # frame = np.ndarray(frame)
        cv2.imshow('frame',result)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break

# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()

It works fine when it outputs the image in cv2.imshow() but the video is working. Can someone help me with this?

edit retag flag offensive close merge delete

Comments

hmm, what exactly is the problem now ?

berak gravatar imageberak ( 2018-05-14 06:15:05 -0500 )edit

@berak, I just found out that the value I was giving was wrong. In the process_img, I gave the value 1 to values between the threshold and 0 for not. Instead of 1, I gave 255. And now, it works.

sravagya1991 gravatar imagesravagya1991 ( 2018-05-14 23:09:31 -0500 )edit