Commit d72ddc82 authored by Maksim Shabunin's avatar Maksim Shabunin

Merge pull request #8787 from mshabunin:pr7241

parents 9ea2f521 4ac5f37d
...@@ -36,7 +36,7 @@ img = cv2.imread('messi5.jpg',0) ...@@ -36,7 +36,7 @@ img = cv2.imread('messi5.jpg',0)
**warning** **warning**
Even if the image path is wrong, it won't throw any error, but print img will give you None Even if the image path is wrong, it won't throw any error, but `print img` will give you `None`
### Display an image ### Display an image
...@@ -109,8 +109,8 @@ elif k == ord('s'): # wait for 's' key to save and exit ...@@ -109,8 +109,8 @@ elif k == ord('s'): # wait for 's' key to save and exit
**warning** **warning**
If you are using a 64-bit machine, you will have to modify k = cv2.waitKey(0) line as follows : If you are using a 64-bit machine, you will have to modify `k = cv2.waitKey(0)` line as follows :
k = cv2.waitKey(0) & 0xFF `k = cv2.waitKey(0) & 0xFF`
Using Matplotlib Using Matplotlib
---------------- ----------------
......
...@@ -42,11 +42,11 @@ while(True): ...@@ -42,11 +42,11 @@ while(True):
cap.release() cap.release()
cv2.destroyAllWindows() cv2.destroyAllWindows()
@endcode @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 frame is read correctly, it will be `True`. So you can
check end of the video by checking this return value. check end of the video by checking this return 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 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
...@@ -55,9 +55,9 @@ video) and full details can be seen here: cv::VideoCapture::get() . ...@@ -55,9 +55,9 @@ video) and 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.
For example, I can check the frame width and height by cap.get(3) and cap.get(4). It gives me For example, I can check the frame width and height by `cap.get(cv2.CAP_PROP_FRAME_WIDTH)` and `cap.get(cv2.CAP_PROP_FRAME_HEIGHT)`. It gives me
640x480 by default. But I want to modify it to 320x240. Just use ret = cap.set(3,320) and 640x480 by default. But I want to modify it to 320x240. Just use `ret = cap.set(cv2.CAP_PROP_FRAME_WIDTH,320)` and
ret = cap.set(4,240). `ret = cap.set(cv2.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 error, make sure camera is working fine using any other camera application
(like Cheese in Linux). (like Cheese in Linux).
...@@ -100,7 +100,7 @@ very simple, just use cv2.imwrite(). Here a little more work is required. ...@@ -100,7 +100,7 @@ very simple, just use cv2.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 last one is **isColor** flag. If it is
True, encoder expect color frame, otherwise it works with grayscale frame. `True`, 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
......
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