<jupyter_start><jupyter_text>People Counter Tutorial Check this out: [OpenCV People Counter](https://www.pyimagesearch.com/2018/08/13/opencv-people-counter/).It likely works better.  Setting Up Your EnvironmentI'm using Linux (Ubuntu specifically) for all my work here.  Installing Python  Installing Jupyter  Installing OpenCV<jupyter_code>import cv2
import numpy as np

base = '/home/jeff/src/Jupyter-Notebooks/DatasSets/Images/'

img = cv2.imread(base + 'eagle.png')                           # load color image

imgGS = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)                  # convert color to grayscale
cv2.imwrite(base + "grayscale-eagle.png", imgGS)               # save grayscale image

ret,imgBW = cv2.threshold(imgGS, 127, 255, cv2.THRESH_BINARY)  # binarization
cv2.imwrite(base + "binarization-eagle.png", imgBW)            # save binary image

cv2.imshow('Original image', img)                              # Display original image
cv2.imshow('Grayscale image', imgGS)                           # Display grayscale image
cv2.imshow('Binary image', imgBW)                              # Display binarized image

cv2.waitKey(0)                                                 # wait here but exit with 'q' or ESC in window

cv2.destroyAllWindows()                                        # close all your windows and stop<jupyter_output><empty_output><jupyter_text>Opening Video StreamA video stream may be a video recording in a file or video from a webcam. A VideoCapture object has several properties that you can access and sometimes change:* **CAP_PROP_POS_MSEC** - Current position of the video file in milliseconds or video capture timestamp.* **CAP_PROP_POS_FRAMES** - 0-based index of the frame to be decoded/captured next.* **CAP_PROP_POS_AVI_RATIO** - Relative position of the video file: 0 - start of the film, 1 - end of the film.* **CAP_PROP_FRAME_WIDTH** - Width of the frames in the video stream.* **CAP_PROP_FRAME_HEIGHT** - Height of the frames in the video stream.* **CAP_PROP_FPS** - Frame rate.* **CAP_PROP_FOURCC** - 4-character code of codec.* **CAP_PROP_FRAME_COUNT** - Number of frames in the video file.* **CAP_PROP_FORMAT** - Format of the [Mat][01] objects returned by retrieve() .* **CAP_PROP_MODE** - Backend-specific value indicating the current capture mode.* **CAP_PROP_BRIGHTNESS** - Brightness of the image (only for cameras).* **CAP_PROP_CONTRAST** - Contrast of the image (only for cameras).* **CAP_PROP_SATURATION** - Saturation of the image (only for cameras).* **CAP_PROP_HUE** - Hue of the image (only for cameras).* **CAP_PROP_GAIN** - Gain of the image (only for cameras).* **CAP_PROP_EXPOSURE** - Exposure (only for cameras).* **CAP_PROP_CONVERT_RGB** - Boolean flags indicating whether images should be converted to RGB.* **CAP_PROP_WHITE_BALANCE** - Currently not supported* **CAP_PROP_RECTIFICATION** - Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently)[01]:http://docs.opencv.org/3.3.0/d3/d63/classcv_1_1Mat.html<jupyter_code>class VidCapProp:
    def __init__(self, vidcap):
        self.getall()
    
    def getall(self):
        self.POS_MSEC = vidcap.get(CAP_PROP_POS_MSEC)             # Current position of the video file in milliseconds or video capture timestamp
        self.POS_FRAMES = vidcap.get(CAP_PROP_POS_FRAMES)         # 0-based index of the frame to be decoded/captured next
        self.POS_AVI_RATIO = vidcap.get(CAP_PROP_POS_AVI_RATIO)   # Relative position of the video file: 0 - start of the film, 1 - end of the film
        self.FRAME_WIDTH = vidcap.get(CAP_PROP_FRAME_WIDTH)       # Width of the frames in the video stream
        self.FRAME_HEIGHT = vidcap.get(CAP_PROP_FRAME_HEIGHT)     # Height of the frames in the video stream
        self.FPS = vidcap.get(CAP_PROP_FPS)                       # Frame rate
        self.FOURCC = vidcap.get(CAP_PROP_FOURCC)                 # 4-character code of codec
        self.FRAME_COUNT = vidcap.get(CAP_PROP_FRAME_COUNT)       # Number of frames in the video file
        self.FORMAT = vidcap.get(CAP_PROP_FORMAT)                 # Format of the Mat objects returned by retrieve()
        self.MODE = vidcap.get(CAP_PROP_MODE)                     # Backend-specific value indicating the current capture mode
        self.BRIGHTNESS = vidcap.get(CAP_PROP_BRIGHTNESS)         # Brightness of the image (only for cameras)
        self.CONTRAST = vidcap.get(CAP_PROP_CONTRAST)             # Contrast of the image (only for cameras)
        self.SATURATION = vidcap.get(CAP_PROP_SATURATION)         # Saturation of the image (only for cameras)
        self.HUE = vidcap.get(CAP_PROP_HUE)                       # Hue of the image (only for cameras)
        self.GAIN = vidcap.get(CAP_PROP_GAIN)                     # Gain of the image (only for cameras)
        self.EXPOSURE = vidcap.get(CAP_PROP_EXPOSURE)             # Exposure (only for cameras)
        self.CONVERT_RGB = vidcap.get(CAP_PROP_CONVERT_RGB)       # Boolean flags indicating whether images should be converted to RGB
        self.WHITE_BALANCE = vidcap.get(CAP_PROP_WHITE_BALANCE)   # Currently not supported
        self.RECTIFICATION = vidcap.get(CAP_PROP_RECTIFICATION)   # Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently)
        
    def printall(self):
        
import numpy as np
import cv2

cap = cv2.VideoCapture(0)

#show all video properties
for i in range(19):
    print(i, cap.get(i))

cap.set(3,160) #set width
cap.set(4,120) #set height
    
while(cap.isOpened()):
    ret, frame = cap.read()
    try:
        cv2.imshow('Frame',frame)
    except:
        print('EOF')
        break

    k = cv2.waitKey(30) & 0xff
    if k == 27:
        break

cap.release()
cv2.destroyAllWindows()<jupyter_output>0 0.0
1 -1.0
2 -1.0
3 640.0
4 480.0
5 30.0
6 1196444237.0
7 -1.0
8 16.0
9 1196444237.0
10 0.5019607843137255
11 0.12549019607843137
12 0.12549019607843137
13 -1.0
14 0.9333333333333333
15 inf
16 1.0
17 -1.0
18 -1.0
{'fraction_non_alphanumeric': 0.09053087036112498, 'fraction_numerical': 0.0382759194541521, 'mean_word_length': 2.8824289405684755, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '171268', 'license': 'Unlicense', 'n_tokens_mistral': 2033, 'n_tokens_neox': 1858, 'n_words': 574, 'path': 'notebooks/Counting People/People-Counter-Tutorial.ipynb', 'repo_name': 'jeffskinnerbox/computer-vision', 'size': '6009'}