« first day (1524 days earlier)      last day (1829 days later) » 

4:14 AM
I have a "simple" task that I cant figure out how to do. Essentially I want to convert all values in an array that dont equal (1,1,1) to (0,0,0)
 
 
4 hours later…
8:36 AM
1 message moved from Python
 
 
2 hours later…
10:39 AM
1 message moved from Python
 
 
11 hours later…
9:48 PM
does anyone know why I'm getting the same first from for the following OpenCV code?
path = 'ScreenRecording_01-08-2019 23-21-21.MP4'
cap = cv2.VideoCapture(path)

fps = cap.get(cv2.CAP_PROP_FPS)
total_num_of_frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
print(f'file: {path}, # frames: {total_num_of_frames}, '
      f'WxH: {width}x{height}, fps: {fps}')

Showing an image. Why must be it be so difficult after over 5 decades of computers.

cap.isOpened()

def set_frame_idx(idx):
    global cap
 
The same what?
 
same frame* okay!
 
you can edit/delete messages for 2 minutes in chat
I meant editing the original :P
good job getting the indentation right
so please try again, even with your clarification I don't understand what 1. the expected behaviour vs 2. the actual behaviour is
 
nope.
indent.works() == False
I should be getting 600 frame, but keep getting first frame.
other peoples answer just mention to do what I have done to get any frame from a video.
it's a OpenCV question, not a python one so prob won't be so clear.
 
side note: I don't think you need global cap inside set_frame_idx because you can mutate global names, you just can't rebind then in the original namespace without the global keyword
@user14492 that part I understood
 
9:53 PM
good to know
 
less-side note: you're returning None from set_frame_idx for an invalid index which will quickly give you an error when you try to unpack that. I suggest raising an explicit error in that case.
 
thanks
 
OK, I've found the docs for VideoCapture and .set and cv.CAP_PROP_POS_FRAMES and .read:
https://docs.opencv.org/master/d8/dfe/classcv_1_1VideoCapture.html#ac4107fb146a762454a8a87715d9b7c96
https://docs.opencv.org/master/d8/dfe/classcv_1_1VideoCapture.html#a8c6d8c2d37505b5ca61ffd4bb54e9a7c
https://docs.opencv.org/master/d4/d15/group__videoio__flags__base.html#ggaeb8dd9c89c10a5c63c139bf7c4f5704da6223452891755166a4fd5173ea257068
https://docs.opencv.org/master/d8/dfe/classcv_1_1VideoCapture.html#a473055e77dd7faa4d26d686226b292c1
at first glance it seems it should work
have you looked at the return value from .read()?
oh, also, in python you can chain comparison operators and have if 0 <= idx <= total_num_of_frames: and it will mean what you have now
oh, also check the return value from.set
also you should probably have idx < total_num_of_frames on the upper bound because the index is 0-based, just like in python
 

« first day (1524 days earlier)      last day (1829 days later) »