get frame from video with CV_CAP_PROP_POS_FRAMES in opencv python
<p>I am trying to detect a (photography) flash in a video using OpenCV.</p>

<p>I detected the frame in which the flash occurs (average brightness above a threshold) and now I'd like to get the <strong>frame number</strong>.</p>

<p>I tried using CV_CAP_PROP_POS_FRAMES <a href="http://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=capture.get#videocapture-get" rel="nofollow noreferrer">from the OpenCV docs</a> without any success.</p>

<pre><code>import numpy as np 
import cv2

cap = cv2.VideoCapture('file.MOV')

while(cap.isOpened()):
    ret, frame = cap.read()

    BW = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
    h,s,v = cv2.split(hsv)
    average = np.average(v) #computes the average brightness

    if average &gt; 200: #flash is detected
        cv2.imshow('frame',BW)
        frameid = cap.get(CV_CAP_PROP_POS_FRAMES) # &lt;--- this line does not work 
        print(frameid)
    if cv2.waitKey(1) &amp; 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()
</code></pre>

<p>Any tips ?</p>