Exemple #1
0
def main():
    capture = cv2.VideoCapture(0)
    capture.set(3, config.camWidth)
    capture.set(4, config.camHeight)
    capture.set(5, config.camFPS)

    info_logger.camera_settings(capture)

    return capture
Exemple #2
0
def main():
    '''Initialise and apply camera settings'''
    capture = cv2.VideoCapture(0)
    capture.set(3, handle_config.CAM_WIDTH)
    capture.set(4, handle_config.CAM_HEIGHT)
    capture.set(5, handle_config.CAM_FPS)
    time.sleep(5)
    capture.set(15, handle_config.CAM_EXPOSURE)

    info_logger.camera_settings(capture)

    return capture
    def _reader(self):
        while self.run:
            ret, frame = self.cap.read()
            if not ret:  # capture frame error
                print('RET error: ', self.camera, datetime.now().time())

                print('Releasing Camera...')
                self.cap.release()
                print('Setting up Camera...')
                self.cap = cv2.VideoCapture(self.camera, cv2.CAP_DSHOW)

                self.cap.set(3, handle_config.CAM_WIDTH)  # CAM WIDTH
                self.cap.set(4, handle_config.CAM_HEIGHT)  # CAM HEIGHT
                # self.cap.set(5, handle_config.CAM_FPS)
                time.sleep(5)
                self.cap.set(15, handle_config.CAM_EXPOSURE)  # CAM EXPOSURE

                for x in range(10):  # WARM UP CAM BY GRABBING 10 IMAGES...
                    _, self.frame = self.cap.read()

                info_logger.camera_settings(self.camera, self.cap)
                print('Camera Reset...?')

                continue
            if np.sum(frame) == 0:  # frame empty for some reason
                print('Empty Frame error: ', self.camera,
                      datetime.now().time())

                print('Releasing Camera...')
                self.cap.release()
                print('Setting up Camera...')
                self.cap = cv2.VideoCapture(self.camera, cv2.CAP_DSHOW)

                self.cap.set(3, handle_config.CAM_WIDTH)  # CAM WIDTH
                self.cap.set(4, handle_config.CAM_HEIGHT)  # CAM HEIGHT
                # self.cap.set(5, handle_config.CAM_FPS)
                time.sleep(5)
                self.cap.set(15, handle_config.CAM_EXPOSURE)  # CAM EXPOSURE

                for x in range(10):  # WARM UP CAM BY GRABBING 10 IMAGES...
                    _, self.frame = self.cap.read()

                info_logger.camera_settings(self.camera, self.cap)
                print('Camera Reset...?')

                continue

            dim = (3840, 2160)
            resized = cv2.resize(frame, dim, interpolation=cv2.INTER_AREA)
            self.frame = resized
            self.needImg = False
    def __init__(self, camera):
        self.needImg = False
        self.camera = camera
        print('Start Cam: ', self.camera, datetime.now().time())
        self.cap = cv2.VideoCapture(self.camera, cv2.CAP_DSHOW)

        self.cap.set(3, handle_config.CAM_WIDTH)  # CAM WIDTH
        self.cap.set(4, handle_config.CAM_HEIGHT)  # CAM HEIGHT
        # self.cap.set(5, handle_config.CAM_FPS)
        time.sleep(5)
        self.cap.set(15, handle_config.CAM_EXPOSURE)  # CAM EXPOSURE

        for x in range(10):  # WARM UP CAM BY GRABBING 10 IMAGES...
            _, self.frame = self.cap.read()

        info_logger.camera_settings(self.camera, self.cap)

        self.run = True
        self.t = threading.Thread(target=self._reader)
        self.t.daemon = True
        self.t.start()
Exemple #5
0
# AIO DLL
import clr
my_path = os.path.abspath(os.path.dirname(__file__))
AIO_DLL = clr.AddReference(my_path + '/AIOWDMNet.dll')
from AIOWDMNet import AIOWDM  # pylint: disable=E0401
AIO_INSTANCE = AIOWDM()
AIO_INSTANCE.RelOutPort(0, 0, 0)  # Reset AIO to empty

CAPTURE = WebcamVideoStream(src=0).start()  # Get camera stream
CAPTURE.stream.set(3, handle_config.CAM_WIDTH)
CAPTURE.stream.set(4, handle_config.CAM_HEIGHT)
CAPTURE.stream.set(5, 900)
time.sleep(2)
CAPTURE.stream.set(cv2.CAP_PROP_EXPOSURE, -6.0)
CAM_FRAME = CAPTURE.read()  # Read frame from camera
info_logger.camera_settings(CAPTURE.stream)

app = running_window.RunningWindow()  # GetUI instance
app.start()  # Start UI

OUTPUT = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]  # current AIO output
AIO_PASS_FAIL_PULSE = []  # array to hold Lane AIO Pass/Fail
AIO_ACTIONS = []  # array to hold AIO Values
LANE_FLAG = []  # array to hold Lane AIO Outputs
THREADS = []  # array to hold threads
THRESHOLD_IMG = []  # shared img
RECTS_ARR = []  # array to hold rectangles
PREV_RECTS_ARR = []  # array to hold last rectangles
BOX_ARR = []  # array to hold contours
AVG_WIDTHS_CURRENT = [
]  # array to hold [0] current avg width [1] total scanned