File: size_test.py

package info (click to toggle)
opencv 2.1.0-3%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 68,800 kB
  • ctags: 52,010
  • sloc: cpp: 554,793; xml: 475,942; ansic: 153,396; python: 18,622; sh: 428; makefile: 111
file content (54 lines) | stat: -rwxr-xr-x 1,361 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
This script will test HighGUI's cvGetCaptureProperty functionality
for correct returnvalues of width and height information for different video formats
"""

# import the necessary things for OpenCV and comparson routine
import os
from cv import *
from highgui import *
#import python
#from python.highgui import *


# path to images and videos  we need
PREFIX		=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/")


# this is the folder with the videos and images
# and name of output window
IMAGES		= PREFIX+"images/"
VIDEOS		= PREFIX+"videos/"


# testing routine, seeks through file and compares read images with frames in COMPARISON
def size_ok(FILENAME):
  # create a video reader using the tiny videofile VIDEOS+FILENAME
  video=cvCreateFileCapture(VIDEOS+FILENAME)

  if video is None:
    # couldn't open video (FAIL)
    return 1

  # get width and height information via HighGUI's cvGetCaptureProperty function
  w=cvGetCaptureProperty(video,CV_CAP_PROP_FRAME_WIDTH)
  h=cvGetCaptureProperty(video,CV_CAP_PROP_FRAME_HEIGHT)

  # get an image to compare
  image=cvQueryFrame(video)
  
  if image is None:
    return 1
  
  image = cvCloneImage (image)
  
  if (w!=image.width) or (h!=image.height):
    # dimensions don't match parameters (FAIL)
    return 1

  del video
  del image
  # everything is fine (PASS)
  return 0