Module Expr Str Import alias identifier Import alias ImportFrom alias ImportFrom alias alias alias Import alias ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad Num NameLoad kwarg body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr TupleLoad Num Num If CompareIsNot NameLoad NameLoad body Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad Num Assign TupleStore NameStore NameStore SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Slice Num Assign AttributeStore NameLoad attr TupleLoad NameLoad NameLoad If CompareIsNot NameLoad NameLoad body Assign TupleStore NameStore NameStore Call NameLoad NameLoad Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr TupleLoad NameLoad NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Pass decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr If CompareIs AttributeLoad NameLoad attr NameLoad body Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad Num AttributeLoad NameLoad attr orelse Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad NameLoad attr NameLoad If CompareGt AttributeLoad NameLoad attr Num body Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad Num AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr Num BinOpMult BinOpMult Call AttributeLoad NameLoad attr Num Num AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad keyword AttributeLoad NameLoad attr Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return NameLoad decorator_list decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam defaults kwarg body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr TupleStore NameStore NameStore TupleLoad Num Num Assign NameStore ListLoad Assign NameStore ListLoad For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad body Assign NameStore ListLoad ListLoad NameLoad NameLoad Num ListLoad BinOpAdd NameLoad Num NameLoad Num ListLoad BinOpAdd NameLoad Num BinOpAdd NameLoad Num Num ListLoad NameLoad BinOpAdd NameLoad Num Num Expr Call AttributeLoad SubscriptLoad ListLoad NameLoad NameLoad Index BinOpMod BinOpAdd NameLoad NameLoad Num attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr ListLoad ListLoad BinOpMult NameLoad NameLoad Num BinOpMult Num BinOpSub NameLoad Num ListLoad Num BinOpMult NameLoad NameLoad BinOpMult Num BinOpSub NameLoad Num ListLoad Num Num Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr ListLoad Num Num Num Num Assign AttributeStore NameLoad attr Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults TupleLoad Num Num Num body Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num Num AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Index Num Assign AttributeStore NameLoad attr BinOpAdd SubscriptLoad AttributeLoad NameLoad attr Slice Num TupleLoad Num For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr BinOpMult NameLoad Num NameLoad AttributeLoad NameLoad attr keyword Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore AttributeLoad NameLoad attr AugAssignAdd AttributeStore NameLoad attr BinOpDiv Num Num Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr ListLoad BinOpMult Num NameLoad BinOpMult Num NameLoad Num Assign NameStore BinOpAdd BinOpDiv NameLoad Num BinOpDiv BinOpMult Call NameLoad BinOpMult NameLoad Num NameLoad Num Assign TupleStore NameStore NameStore TupleLoad Call NameLoad NameLoad Call NameLoad NameLoad Assign NameStore BinOpMult BinOpMult Call AttributeLoad NameLoad attr ListLoad Call NameLoad BinOpMult Num NameLoad Call NameLoad BinOpMult Num NameLoad Num NameLoad Num Assign NameStore BinOpAdd BinOpAdd NameLoad BinOpMult Call AttributeLoad NameLoad attr ListLoad BinOpMult Call NameLoad NameLoad NameLoad BinOpMult Call NameLoad NameLoad NameLoad NameLoad Num NameLoad Assign NameStore BinOpAdd NameLoad NameLoad Assign TupleStore NameStore AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr TupleLoad Num Num Num Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr TupleLoad Num Num Num decorator_list decorator_list Assign NameStore Call NameLoad keyword NameLoad Assign NameStore Call NameLoad keyword Str keyword Str keyword Str FunctionDef arguments args NameParam NameParam defaults Num SubscriptLoad NameLoad Index Str body Expr Str Assign NameStore Call AttributeLoad Call NameLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Str If BoolOpAnd CompareGt Call NameLoad NameLoad Num CompareEq Call NameLoad SubscriptLoad NameLoad Index Num Num Call AttributeLoad SubscriptLoad NameLoad Index Num attr body Assign SubscriptStore NameLoad Index Num BinOpAdd BinOpAdd SubscriptLoad NameLoad Index Num Str SubscriptLoad NameLoad Index Num Delete SubscriptDel NameLoad Index Num Assign NameStore SubscriptLoad NameLoad Index Num TryExcept body Assign NameStore Call NameLoad NameLoad handlers ExceptHandler type NameLoad body Pass Assign NameStore Call NameLoad GeneratorExp Call AttributeLoad NameLoad attr Str comprehension NameStore SubscriptLoad NameLoad Slice Num Assign NameStore NameLoad If CompareEq NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Str NameLoad NameLoad TryExcept body Assign NameStore Call NameLoad NameLoad handlers ExceptHandler body Pass orelse Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareIn Str NameLoad body Assign TupleStore NameStore NameStore Call NameLoad NameLoad Call AttributeLoad SubscriptLoad NameLoad Index Str attr Str Expr Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr NameLoad If BoolOpOr CompareIs NameLoad NameLoad UnaryOpNot Call AttributeLoad NameLoad attr body Print Str NameLoad If CompareIsNot NameLoad NameLoad body Return Call NameLoad NameLoad NameLoad Return NameLoad decorator_list If CompareEq NameLoad Str body Import alias Import alias Print NameLoad Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Slice Num Str Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Str If CompareEq Call NameLoad NameLoad Num body Assign NameStore ListLoad Num Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore Num While NameLoad body Assign NameStore ListLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad NameLoad Assign NameStore BinOpBitAnd Num Call AttributeLoad NameLoad attr Num If CompareEq NameLoad Num body Break If CompareEq NameLoad Call NameLoad Str body For TupleStore NameStore NameStore Call NameLoad NameLoad body Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Print NameLoad Str AugAssignAdd NameStore Num Expr Call AttributeLoad NameLoad attr
N/A N/A 
Video capture sample.

Sample shows how VideoCapture class can be used to acquire video
frames from a camera of a movie file. Also the sample provides
an example of procedural video generation by an object, mimicking
the VideoCapture interface (see Chess class).

'create_capture' is a convinience function for capture creation,
falling back to procedural video in case of error.

Usage:
    video.py [--shotdir <shot path>] [source0] [source1] ...'

    sourceN is an
     - integer number for camera capture
     - name of video file
     - synth:<params> for procedural video

Synth examples:
    synth:bg=../cpp/lena.jpg:noise=0.1
    synth:class=chess:bg=../cpp/lena.jpg:noise=0.1:size=640x480

Keys:
    ESC    - exit
    SPACE  - save current frame to <shot path> directory

 N/A numpy np N/A cv2 time clock numpy pi sin cos N/A common VideoSynthBase N/A object N/A __init__ N/A N/A self size noise bg N/A None 0.0 None params N/A N/A N/A self bg None N/A N/A self frame_size N/A 640 480 N/A N/A bg None N/A N/A N/A self bg N/A N/A cv2 imread bg 1 N/A N/A h w N/A N/A N/A self bg shape N/A 2 N/A N/A self frame_size N/A w h N/A N/A size None N/A N/A N/A w h N/A map int N/A N/A size split x N/A N/A self frame_size N/A w h N/A N/A self bg N/A N/A cv2 resize N/A self bg N/A self frame_size N/A N/A self noise N/A float noise N/A render N/A N/A self dst N/A N/A N/A N/A read N/A N/A self dst N/A None N/A N/A N/A w h N/A self frame_size N/A N/A N/A self bg None N/A N/A buf N/A N/A np zeros N/A h w 3 N/A np uint8 N/A N/A buf N/A N/A N/A self bg copy N/A N/A N/A self render buf N/A N/A N/A self noise 0.0 N/A N/A noise N/A N/A np zeros N/A h w 3 N/A np int8 N/A N/A N/A cv2 randn noise N/A N/A np zeros 3 N/A N/A N/A N/A np ones 3 255 N/A self noise N/A buf N/A N/A cv2 add buf noise dtype N/A cv2 CV_8UC3 N/A N/A True buf N/A isOpened N/A N/A self N/A N/A N/A True N/A N/A Chess N/A VideoSynthBase N/A __init__ N/A N/A self N/A kw N/A N/A N/A N/A N/A super Chess self __init__ kw N/A N/A w h N/A self frame_size N/A N/A self grid_size N/A sx sy N/A 10 7 N/A white_quads N/A N/A black_quads N/A N/A N/A i j N/A N/A np ndindex sy sx N/A N/A q N/A N/A j i 0 N/A N/A j 1 i 0 N/A N/A j 1 N/A i 1 0 N/A j N/A i 1 0 N/A N/A N/A N/A N/A white_quads black_quads N/A N/A N/A i j 2 append q N/A N/A self white_quads N/A N/A np float32 white_quads N/A N/A self black_quads N/A N/A np float32 black_quads N/A fx 0.9 N/A N/A self K N/A N/A np float64 N/A N/A N/A fx w 0 N/A 0.5 N/A w 1 N/A 0 N/A fx w N/A 0.5 N/A h 1 N/A 0.0 0.0 1.0 N/A N/A self dist_coef N/A N/A np float64 N/A -0.2 0.1 0 0 N/A N/A self t 0 N/A draw_quads N/A N/A self img quads color N/A N/A 0 255 0 N/A N/A img_quads N/A N/A N/A cv2 projectPoints N/A N/A quads reshape -1 3 N/A self rvec N/A self tvec N/A self K N/A self dist_coef N/A 0 N/A N/A img_quads shape N/A N/A N/A quads shape N/A 2 N/A 2 N/A q img_quads N/A N/A N/A N/A cv2 fillConvexPoly img N/A N/A np int32 N/A q 4 color N/A cv2 CV_AA shift 2 N/A render N/A N/A self dst N/A N/A N/A t N/A self t N/A N/A self t N/A 1.0 30.0 N/A N/A sx sy N/A self grid_size N/A center N/A N/A np array N/A N/A 0.5 sx N/A 0.5 sy 0.0 N/A phi N/A N/A pi 3 N/A N/A N/A sin N/A t 3 pi 8 N/A N/A c s N/A N/A cos phi N/A sin phi N/A ofs N/A N/A N/A N/A np array N/A N/A sin N/A 1.2 t N/A cos N/A 1.8 t 0 sx 0.2 N/A eye_pos N/A N/A center N/A N/A N/A np array N/A N/A N/A cos t c N/A N/A sin t c s 15.0 ofs N/A target_pos N/A center ofs N/A N/A R N/A self tvec N/A N/A common lookat eye_pos target_pos N/A N/A self rvec N/A N/A common mtx2rvec R N/A N/A N/A self draw_quads dst N/A self white_quads N/A 245 245 245 N/A N/A N/A self draw_quads dst N/A self black_quads N/A 10 10 10 N/A N/A N/A classes N/A dict chess Chess N/A presets N/A dict empty synth: lena synth:bg=../cpp/lena.jpg:noise=0.1 chess synth:class=chess:bg=../cpp/lena.jpg:noise=0.1:size=640x480 create_capture N/A N/A source fallback N/A 0 N/A presets N/A chess N/A N/A source: <int> or '<int>|<filename>|synth [:<param_name>=<value> [:...]]'
     N/A source N/A N/A N/A str source strip N/A chunks N/A N/A source split : N/A N/A N/A N/A len chunks 1 N/A N/A len N/A chunks N/A 0 1 N/A N/A N/A chunks N/A 0 isalpha N/A N/A N/A chunks N/A 1 N/A N/A N/A chunks N/A 0 : N/A chunks N/A 1 N/A N/A chunks N/A 0 N/A source N/A chunks N/A 0 N/A N/A N/A source N/A int source N/A N/A N/A ValueError N/A N/A N/A params N/A dict N/A N/A N/A s split = N/A s N/A chunks N/A 1 N/A cap None N/A N/A source synth N/A N/A Class N/A N/A classes get N/A N/A params get class None VideoSynthBase N/A N/A N/A cap N/A Class params N/A N/A N/A N/A N/A N/A cap N/A N/A cv2 VideoCapture source N/A N/A size params N/A N/A N/A w h N/A map int N/A N/A N/A params N/A size split x N/A N/A N/A cap set N/A N/A cv2 cv CV_CAP_PROP_FRAME_WIDTH w N/A N/A N/A cap set N/A N/A cv2 cv CV_CAP_PROP_FRAME_HEIGHT h N/A N/A N/A cap None N/A N/A N/A cap isOpened N/A N/A Warning: unable to open video source:  source N/A N/A fallback None N/A N/A N/A create_capture fallback None N/A cap N/A N/A N/A __name__ __main__ N/A N/A sys N/A getopt N/A __doc__ N/A N/A args sources N/A N/A getopt getopt N/A N/A sys argv N/A 1 shotdir= N/A args N/A dict args N/A shotdir N/A N/A args get --shotdir . N/A N/A N/A len sources 0 N/A N/A sources N/A 0 N/A caps N/A map create_capture sources N/A shot_idx 0 N/A True N/A N/A imgs N/A N/A N/A i cap N/A enumerate caps N/A N/A N/A ret img N/A N/A cap read N/A N/A N/A imgs append img N/A N/A N/A cv2 imshow N/A capture %d i img N/A ch N/A 255 N/A N/A cv2 waitKey 1 N/A N/A ch 27 N/A N/A N/A N/A ch N/A ord N/A N/A N/A i img N/A enumerate imgs N/A N/A fn N/A %s/shot_%d_%03d.bmp N/A shotdir i shot_idx N/A N/A N/A cv2 imwrite fn img N/A fn saved N/A shot_idx 1 N/A N/A N/A cv2 destroyAllWindows