1 Replies - 6486 Views - Last Post: 26 July 2012 - 01:31 AM Rate Topic: -----

#1 kea995  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 8
  • Joined: 19-July 11

OpenCV video - how to take a snapshot/captures a single frame

Posted 25 July 2012 - 04:27 AM

I am new to OpenCV, which I want to use for video.
I would like to capture a single frame and save the frame in a directory.
Could someone help me getting started? So far I just have conection to the web camera:

import cv2.cv as cv
import time

cv.NamedWindow("camera", 1)

capture = cv.CaptureFromCAM(0)

while True:
    img = cv.QueryFrame(capture)
    cv.ShowImage("camera", img)
    if cv.WaitKey(10) == 27:
        break
cv.DestroyAllWindows()




Can I use cv.VideoCapture(0) somehow in the code above?
There is documentation for OpenCv here: http://docs.opencv.org/

Is This A Good Question/Topic? 0
  • +

Replies To: OpenCV video - how to take a snapshot/captures a single frame

#2 kea995  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 8
  • Joined: 19-July 11

Re: OpenCV video - how to take a snapshot/captures a single frame

Posted 26 July 2012 - 01:31 AM

I found out. The following code will do what I wanted to:



import cv2.cv as cv
import time

cv.NamedWindow("camera", 1)

capture = cv.CaptureFromCAM(0)

while True:
    img = cv.QueryFrame(capture)

    # cv.ShowImage("camera", img)

    cv.SaveImage('test1.jpg', img)
	
    if cv.WaitKey(10) == 27:
        break
cv.DestroyAllWindows()







Was This Post Helpful? 1
  • +
  • -

Page 1 of 1