Esempio n. 1
0
# (here we just do nothing)


def nothing(x):
    pass


#####################################################################

# define video capture object

try:
    # to use a non-buffered camera stream (via a separate thread)

    import camera_stream
    cap = camera_stream.CameraVideoStream()

except:
    # if not then just use OpenCV default

    print("INFO: camera_stream class not found - camera input may be buffered")
    cap = cv2.VideoCapture()

# define display window name

windowName = "Live Camera Input"  # window name

# if command line arguments are provided try to read video_name
# otherwise default to capture from attached H/W camera

if (((args.video_file) and (cap.open(str(args.video_file))))
Esempio n. 2
0

def nothing(x):
    pass


#####################################################################

# define video capture object

try:
    # to use a non-buffered camera stream (via a separate thread)

    if not (args.video_file):
        import camera_stream
        cap = camera_stream.CameraVideoStream(use_tapi=True)
    else:
        cap = cv2.VideoCapture()  # not needed for video files

except BaseException:
    # if not then just use OpenCV default

    print("INFO: camera_stream class not found - camera input may be buffered")
    cap = cv2.VideoCapture()

# define display window name

window_name = "Largest Area Contour"  # window name
window_name2 = "All Contours"  # window name

# if command line arguments are provided try to read video_name
            image[j, i] = int(
                c * math.log(1 + ((math.exp(sigma) - 1) * image[j, i])))

    return image


#####################################################################

# define video capture object

try:
    # to use a non-buffered camera stream (via a separate thread)

    if not (args.video_file):
        import camera_stream
        cap = camera_stream.CameraVideoStream(use_tapi=False)
    else:
        cap = cv2.VideoCapture()  # not needed for video files

except BaseException:
    # if not then just use OpenCV default

    print("INFO: camera_stream class not found - camera input may be buffered")
    cap = cv2.VideoCapture()

# define display window name

window_name = "Live Camera Input"  # window name
window_name2 = "Logarithmic Transform"  # window name

# if command line arguments are provided try to read video_file
Esempio n. 4
0
    def __init__(self, args):

        self.xiema = args.ximea
        self.zed = args.zed
        self.cameras_opened = False

        if args.ximea:

            # ximea requires specific API offsets in the open commands

            self.camL = cv2.VideoCapture()
            self.camR = cv2.VideoCapture()

            if not(
                (self.camL.open(
                    cv2.CAP_XIAPI)) and (
                    self.camR.open(
                        cv2.CAP_XIAPI +
                    1))):
                print("Cannot open pair of Ximea cameras connected.")
            exit()

        elif args.zed:

            # ZED is a single camera interface with L/R returned as 1 image

            try:
                # to use a non-buffered camera stream (via a separate thread)
                # no T-API use, unless additional code changes later

                import camera_stream
                self.camZED = camera_stream.CameraVideoStream()

            except BaseException:
                # if not then just use OpenCV default

                print("INFO: camera_stream class not found - \
                        camera input may be buffered")
                self.camZED = cv2.VideoCapture()

            if not(self.camZED.open(args.camera_to_use)):
                print(
                    "Cannot open connected ZED stereo camera as camera #: ",
                    args.camera_to_use)
                exit()

            # report resolution currently in use for ZED (as various
            # options exist) can use .get()/.set() to read/change also

            _, frame = self.camZED.read()
            height, width, channels = frame.shape
            print()
            print("ZED left/right resolution: ",
                  int(width / 2), " x ", int(height))
            print()

        else:

            # by default two standard system connected cams from the default
            # video backend

            self.camL = cv2.VideoCapture()
            self.camR = cv2.VideoCapture()
            if not(
                (self.camL.open(
                    args.camera_to_use)) and (
                    self.camR.open(
                        args.camera_to_use +
                    2))):
                print(
                    "Cannot open pair of system cameras connected \
                    starting at camera #:",
                    args.camera_to_use)
                exit()

        self.cameras_opened = True
Esempio n. 5
0

def nothing(x):
    pass


#####################################################################

# define video capture object

try:
    # to use a non-buffered camera stream (via a separate thread)

    if not (args.video_file):
        import camera_stream
        cap = camera_stream.CameraVideoStream(use_tapi=args.opencl)
    else:
        cap = cv2.VideoCapture()  # not needed for video files

except BaseException:
    # if not then just use OpenCV default

    print("INFO: camera_stream class not found - camera input may be buffered")
    cap = cv2.VideoCapture()

# define display window name

window_name = "Live Camera Input"  # window name
window_name2 = "Gaussian Smoothing"  # window name

# setup OpenCL if specified on command line only
Esempio n. 6
0

def nothing(x):
    pass


#####################################################################

# define video capture object

try:
    # to use a non-buffered camera stream (via a separate thread)

    if not (args.video_file):
        import camera_stream
        cap = camera_stream.CameraVideoStream()  # T-API done later
    else:
        cap = cv2.VideoCapture()  # not needed for video files

except BaseException:
    # if not then just use OpenCV default

    print("INFO: camera_stream class not found - camera input may be buffered")
    cap = cv2.VideoCapture()

# define display window name

window_name = "HOG pedestrain detection"  # window name

# if command line arguments are provided try to read video_name
# otherwise default to capture from attached H/W camera
Esempio n. 7
0

def nothing(x):
    pass


#####################################################################

# define video capture object

try:
    # to use a non-buffered camera stream (via a separate thread)

    if not (args.video_file):
        import camera_stream
        cap = camera_stream.CameraVideoStream()  # T-API breaks code
    else:
        cap = cv2.VideoCapture()  # not needed for video files

except BaseException:
    # if not then just use OpenCV default

    print("INFO: camera_stream class not found - camera input may be buffered")
    cap = cv2.VideoCapture()

# define display window name

window_name = "Live Camera Input"  # window name

# if command line arguments are provided try to read video_name
# otherwise default to capture from attached H/W camera
Esempio n. 8
0
    path_to_config_file = args.config_file_xml
    manual_camera_calibration_available = True

else:
    print("Warning - no serial number or config file specified.")
    print()

################################################################################

# define video capture object as a threaded video stream

try:
    # to use a non-buffered camera stream (via a separate thread)

    import camera_stream
    zed_cam = camera_stream.CameraVideoStream()

except BaseException:
    # if not then just use OpenCV default

    print("INFO: camera_stream class not found - camera input may be buffered")
    zed_cam = cv2.VideoCapture()

zed_cam.open(args.camera_to_use)

# check open and read video frame

if (zed_cam.isOpened()):
    ret, frame = zed_cam.read()
    print("INFO: camera backend is:", zed_cam.getBackendName())
    print()