Commit 3ada5974 authored by collin's avatar collin

grammar corrections for python gui docs

parent 027769bf
...@@ -4,21 +4,21 @@ Gui Features in OpenCV {#tutorial_py_table_of_contents_gui} ...@@ -4,21 +4,21 @@ Gui Features in OpenCV {#tutorial_py_table_of_contents_gui}
- @subpage tutorial_py_image_display - @subpage tutorial_py_image_display
Learn to load an Learn to load an
image, display it and save it back image, display it, and save it back
- @subpage tutorial_py_video_display - @subpage tutorial_py_video_display
Learn to play videos, Learn to play videos,
capture videos from Camera and write it as a video capture videos from a camera, and write videos
- @subpage tutorial_py_drawing_functions - @subpage tutorial_py_drawing_functions
Learn to draw lines, Learn to draw lines,
rectangles, ellipses, circles etc with OpenCV rectangles, ellipses, circles, etc with OpenCV
- @subpage tutorial_py_mouse_handling - @subpage tutorial_py_mouse_handling
Draw stuffs with your Draw stuff with your
mouse mouse
- @subpage tutorial_py_trackbar - @subpage tutorial_py_trackbar
......
...@@ -4,19 +4,19 @@ Getting Started with Videos {#tutorial_py_video_display} ...@@ -4,19 +4,19 @@ Getting Started with Videos {#tutorial_py_video_display}
Goal Goal
---- ----
- Learn to read video, display video and save video. - Learn to read video, display video, and save video.
- Learn to capture from Camera and display it. - Learn to capture video from a camera and display it.
- You will learn these functions : **cv.VideoCapture()**, **cv.VideoWriter()** - You will learn these functions : **cv.VideoCapture()**, **cv.VideoWriter()**
Capture Video from Camera Capture Video from Camera
------------------------- -------------------------
Often, we have to capture live stream with camera. OpenCV provides a very simple interface to this. Often, we have to capture live stream with a camera. OpenCV provides a very simple interface to do this.
Let's capture a video from the camera (I am using the in-built webcam of my laptop), convert it into Let's capture a video from the camera (I am using the built-in webcam on my laptop), convert it into
grayscale video and display it. Just a simple task to get started. grayscale video and display it. Just a simple task to get started.
To capture a video, you need to create a **VideoCapture** object. Its argument can be either the To capture a video, you need to create a **VideoCapture** object. Its argument can be either the
device index or the name of a video file. Device index is just the number to specify which camera. device index or the name of a video file. A device index is just the number to specify which camera.
Normally one camera will be connected (as in my case). So I simply pass 0 (or -1). You can select Normally one camera will be connected (as in my case). So I simply pass 0 (or -1). You can select
the second camera by passing 1 and so on. After that, you can capture frame-by-frame. But at the the second camera by passing 1 and so on. After that, you can capture frame-by-frame. But at the
end, don't forget to release the capture. end, don't forget to release the capture.
...@@ -46,16 +46,16 @@ while True: ...@@ -46,16 +46,16 @@ while True:
# When everything done, release the capture # When everything done, release the capture
cap.release() cap.release()
cv.destroyAllWindows()@endcode cv.destroyAllWindows()@endcode
`cap.read()` returns a bool (`True`/`False`). If frame is read correctly, it will be `True`. So you can `cap.read()` returns a bool (`True`/`False`). If the frame is read correctly, it will be `True`. So you can
check end of the video by checking this return value. check for the end of the video by checking this returned value.
Sometimes, cap may not have initialized the capture. In that case, this code shows error. You can Sometimes, cap may not have initialized the capture. In that case, this code shows an error. You can
check whether it is initialized or not by the method **cap.isOpened()**. If it is `True`, OK. check whether it is initialized or not by the method **cap.isOpened()**. If it is `True`, OK.
Otherwise open it using **cap.open()**. Otherwise open it using **cap.open()**.
You can also access some of the features of this video using **cap.get(propId)** method where propId You can also access some of the features of this video using **cap.get(propId)** method where propId
is a number from 0 to 18. Each number denotes a property of the video (if it is applicable to that is a number from 0 to 18. Each number denotes a property of the video (if it is applicable to that
video) and full details can be seen here: cv::VideoCapture::get(). video). Full details can be seen here: cv::VideoCapture::get().
Some of these values can be modified using **cap.set(propId, value)**. Value is the new value you Some of these values can be modified using **cap.set(propId, value)**. Value is the new value you
want. want.
...@@ -63,13 +63,13 @@ For example, I can check the frame width and height by `cap.get(cv.CAP_PROP_FRAM ...@@ -63,13 +63,13 @@ For example, I can check the frame width and height by `cap.get(cv.CAP_PROP_FRAM
640x480 by default. But I want to modify it to 320x240. Just use `ret = cap.set(cv.CAP_PROP_FRAME_WIDTH,320)` and 640x480 by default. But I want to modify it to 320x240. Just use `ret = cap.set(cv.CAP_PROP_FRAME_WIDTH,320)` and
`ret = cap.set(cv.CAP_PROP_FRAME_HEIGHT,240)`. `ret = cap.set(cv.CAP_PROP_FRAME_HEIGHT,240)`.
@note If you are getting error, make sure camera is working fine using any other camera application @note If you are getting an error, make sure your camera is working fine using any other camera application
(like Cheese in Linux). (like Cheese in Linux).
Playing Video from file Playing Video from file
----------------------- -----------------------
It is same as capturing from Camera, just change camera index with video file name. Also while Playing video from file is the same as capturing it from camera, just change the camera index to a video file name. Also while
displaying the frame, use appropriate time for `cv.waitKey()`. If it is too less, video will be very displaying the frame, use appropriate time for `cv.waitKey()`. If it is too less, video will be very
fast and if it is too high, video will be slow (Well, that is how you can display videos in slow fast and if it is too high, video will be slow (Well, that is how you can display videos in slow
motion). 25 milliseconds will be OK in normal cases. motion). 25 milliseconds will be OK in normal cases.
...@@ -96,23 +96,23 @@ cap.release() ...@@ -96,23 +96,23 @@ cap.release()
cv.destroyAllWindows() cv.destroyAllWindows()
@endcode @endcode
@note Make sure proper versions of ffmpeg or gstreamer is installed. Sometimes, it is a headache to @note Make sure a proper version of ffmpeg or gstreamer is installed. Sometimes it is a headache to
work with Video Capture mostly due to wrong installation of ffmpeg/gstreamer. work with video capture, mostly due to wrong installation of ffmpeg/gstreamer.
Saving a Video Saving a Video
-------------- --------------
So we capture a video, process it frame-by-frame and we want to save that video. For images, it is So we capture a video and process it frame-by-frame, and we want to save that video. For images, it is
very simple, just use `cv.imwrite()`. Here a little more work is required. very simple: just use `cv.imwrite()`. Here, a little more work is required.
This time we create a **VideoWriter** object. We should specify the output file name (eg: This time we create a **VideoWriter** object. We should specify the output file name (eg:
output.avi). Then we should specify the **FourCC** code (details in next paragraph). Then number of output.avi). Then we should specify the **FourCC** code (details in next paragraph). Then number of
frames per second (fps) and frame size should be passed. And last one is **isColor** flag. If it is frames per second (fps) and frame size should be passed. And the last one is the **isColor** flag. If it is
`True`, encoder expect color frame, otherwise it works with grayscale frame. `True`, the encoder expect color frame, otherwise it works with grayscale frame.
[FourCC](http://en.wikipedia.org/wiki/FourCC) is a 4-byte code used to specify the video codec. The [FourCC](http://en.wikipedia.org/wiki/FourCC) is a 4-byte code used to specify the video codec. The
list of available codes can be found in [fourcc.org](http://www.fourcc.org/codecs.php). It is list of available codes can be found in [fourcc.org](http://www.fourcc.org/codecs.php). It is
platform dependent. Following codecs works fine for me. platform dependent. The following codecs work fine for me.
- In Fedora: DIVX, XVID, MJPG, X264, WMV1, WMV2. (XVID is more preferable. MJPG results in high - In Fedora: DIVX, XVID, MJPG, X264, WMV1, WMV2. (XVID is more preferable. MJPG results in high
size video. X264 gives very small size video) size video. X264 gives very small size video)
...@@ -122,7 +122,7 @@ platform dependent. Following codecs works fine for me. ...@@ -122,7 +122,7 @@ platform dependent. Following codecs works fine for me.
FourCC code is passed as `cv.VideoWriter_fourcc('M','J','P','G')` or FourCC code is passed as `cv.VideoWriter_fourcc('M','J','P','G')` or
`cv.VideoWriter_fourcc(*'MJPG')` for MJPG. `cv.VideoWriter_fourcc(*'MJPG')` for MJPG.
Below code capture from a Camera, flip every frame in vertical direction and saves it. The below code captures from a camera, flips every frame in the vertical direction, and saves the video.
@code{.py} @code{.py}
import numpy as np import numpy as np
import cv2 as cv import cv2 as cv
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment