<commit_before>"""
press 'p' to print camera information
press 's' to set camera property. Try 'p' first to see property names then insert them in console.
press 'f' to print measured frame rate (the frequency VideoCapture::read() is called).
"""

import cv2
from time import clock


class OpenCV_Cam(object):

    def __init__(self, src=None):
        self.start_cam(src)
        self.__fcount, self.__frate, self.__start = 0, 0, clock()
    
    @staticmethod
    def cam_count():
        cam_idx = 0
        cap = cv2.VideoCapture(cam_idx)
        while cap.read()[0]:
            cam_idx += 1
            cap = cv2.VideoCapture(cam_idx)
            
        return cam_idx

    def start_cam(self, src=None):
        if src is not None:
            self.cam = VideoCapture(src)
            if not self.cam.isOpened():
                raise ValueError('Cannot open ' + src + 'as VideoCapture')
            return
        
        idx = 1
        cam1, cam2 = cv2.VideoCapture(0), cv2.VideoCapture(1)
        while(cam2.read()[0]):
            cam1.release()
            cam1 = cam2<commit_msg>correct cam.py<commit_after>"""
press 'p' to print camera information
press 's' to set camera property. Try 'p' first to see property names then insert them in console.
press 'f' to print measured frame rate (the frequency VideoCapture::read() is called).
"""

import cv2
from time import clock


class OpenCV_Cam(object):

    def __init__(self, src=None):
        self.start_cam(src)
        self.__fcount, self.__frate, self.__start = 0, 0, clock()
    
    @staticmethod
    def cam_count():
        cam_idx = 0
        cap = cv2.VideoCapture(cam_idx)
        while cap.read()[0]:
            cam_idx += 1
            cap = cv2.VideoCapture(cam_idx)
            
        return cam_idx

    def start_cam(self, src=None):
        if src is not None:
            self.cam = cv2.VideoCapture(src)
            if not self.cam.isOpened():
                raise ValueError('Cannot open ' + src + 'as VideoCapture')
            return
        
        idx = 1
        cam1, cam2 = cv2.VideoCapture(0), cv2.VideoCapture(1)
        while(cam2.read()[0]):
            cam1.release()
            cam1 = cam2
{'fraction_non_alphanumeric': 0.10377787892580792, 'fraction_numerical': 0.018661811561219845, 'mean_word_length': 2.0612813370473537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5432929', 'n_tokens_mistral': 671, 'n_tokens_neox': 652, 'n_words': 200}