Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the first three worked examples.
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/python | ||
|
||
import sys | ||
from opencv import highgui | ||
|
||
def show(filename): | ||
img = highgui.cvLoadImage(filename) | ||
highgui.cvNamedWindow("Example1", highgui.CV_WINDOW_AUTOSIZE) | ||
highgui.cvShowImage("Example1", img) | ||
highgui.cvWaitKey(0) | ||
highgui.cvDestroyWindow("Example1") | ||
|
||
if __name__ == "__main__": | ||
show(sys.argv[1]) | ||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/python | ||
|
||
import sys | ||
from opencv import highgui | ||
|
||
def showavi(filename): | ||
highgui.cvNamedWindow("Example2", highgui.CV_WINDOW_AUTOSIZE) | ||
capture = highgui.cvCreateFileCapture(filename) | ||
|
||
while True: | ||
frame = highgui.cvQueryFrame(capture) | ||
if not frame: | ||
break | ||
highgui.cvShowImage("Example2", frame) | ||
|
||
c = highgui.cvWaitKey(100) | ||
if c == '\x1b': # escape key | ||
break | ||
|
||
highgui.cvReleaseCapture(capture) | ||
highgui.cvDestroyWindow("Example2") | ||
|
||
if __name__ == "__main__": | ||
showavi(sys.argv[1]) | ||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/python | ||
|
||
import sys | ||
from opencv import highgui | ||
|
||
capture = None | ||
slider_pos = 0 | ||
|
||
def on_trackbar_slide(position): | ||
highgui.cvSetCaptureProperty(capture, highgui.CV_CAP_PROP_POS_FRAMES, position) | ||
|
||
def showavi(filename): | ||
highgui.cvNamedWindow("Example3", highgui.CV_WINDOW_AUTOSIZE) | ||
global capture | ||
capture = highgui.cvCreateFileCapture(filename) | ||
|
||
frames = int(highgui.cvGetCaptureProperty(capture, highgui.CV_CAP_PROP_FRAME_COUNT)) | ||
|
||
if frames != 0: | ||
highgui.cvCreateTrackbar("Position", "Example3", slider_pos, frames, on_trackbar_slide) | ||
|
||
while True: | ||
frame = highgui.cvQueryFrame(capture) | ||
if not frame: | ||
break | ||
highgui.cvShowImage("Example3", frame) | ||
|
||
c = highgui.cvWaitKey(100) | ||
if c == '\x1b': # escape key | ||
break | ||
|
||
highgui.cvReleaseCapture(capture) | ||
highgui.cvDestroyWindow("Example3") | ||
|
||
if __name__ == "__main__": | ||
showavi(sys.argv[1]) | ||
sys.exit(0) |