Example #1
0
import time
import cv2
import numpy as np
try:
    from queue import Queue
except ImportError:
    from Queue import Queue
import os
# import threading
import time
import imutils
import numpy, scipy.io
from imutils.video import WebcamVideoStream
from mintsJetson import camReader as cr

cr.printMINTS("fevSen")

cr.printLabel("Logging Inputs")

highResolution = True
imageSave = True
display = True

directory = "/home/teamlary/mintsData/jetson001/"
width = 2592
height = 1944
frameRate = 15

# For Low Resolution
if not highResolution:
    width = 640
Example #2
0
def main():

    cr.printLabel("Initiating Thermal Camera")
    ctx = POINTER(uvc_context)()
    dev = POINTER(uvc_device)()
    devh = POINTER(uvc_device_handle)()
    ctrl = uvc_stream_ctrl()

    res = libuvc.uvc_init(byref(ctx), 0)
    if res < 0:
        print("uvc_init error")
        exit(1)

    try:
        res = libuvc.uvc_find_device(ctx, byref(dev), PT_USB_VID, PT_USB_PID,
                                     0)
        if res < 0:
            print("uvc_find_device error")
            exit(1)

        try:
            res = libuvc.uvc_open(dev, byref(devh))
            if res < 0:
                print("uvc_open error")
                exit(1)

            cr.printLabel("Thermal Camera Initiated")
            cr.printLabel("Thermal Camera Properties:")
            print_device_info(devh)
            print_device_formats(devh)

            frame_formats = uvc_get_frame_formats_by_guid(
                devh, VS_FMT_GUID_Y16)
            if len(frame_formats) == 0:
                print("device does not support Y16")
                exit(1)

            libuvc.uvc_get_stream_ctrl_format_size(
                devh, byref(ctrl), UVC_FRAME_FORMAT_Y16,
                frame_formats[0].wWidth, frame_formats[0].wHeight,
                int(1e7 / frame_formats[0].dwDefaultFrameInterval))

            res = libuvc.uvc_start_streaming(devh, byref(ctrl),
                                             PTR_PY_FRAME_CALLBACK, None, 0)
            if res < 0:
                print("uvc_start_streaming failed: {0}".format(res))
                exit(1)

            try:
                startTime = time.time()
                cr.printLabel("Initiating Checks")
                for n in range(10):
                    print("Check: " + str(n + 1))
                    q.get(True, 500)
                    retLeft, frameLeft = capLeft.read()
                    retRight, frameRight = capRight.read()
                    if not retLeft:
                        print('Empty Left frame')
                    if not retRight:
                        print('Empty Right frame')

                cr.printLabel("Entering While Loop")
                while True:
                    dateTime = datetime.datetime.now()
                    thermalData = q.get(True, 500)
                    retLeft, left = capLeft.read()
                    retRight, right = capRight.read()

                    if not retLeft:
                        print('Empty Left frame')
                    if not retRight:
                        print('Empty Right frame')

                    qThermal.put(cr.thermalRawConvert(thermalData))

                    if (qThermal.full()):
                        print(dateTime)
                        thermal = qThermal.get()
                        if (imageSave):
                            leftImageName = directory + cr.getImagePathTail(
                                dateTime, 'left')
                            rightImageName = directory + cr.getImagePathTail(
                                dateTime, 'right')
                            thermalImageName = directory + cr.getImagePathTail(
                                dateTime, 'thermal')

                            cv2.imwrite(leftImageName, left)
                            cv2.imwrite(rightImageName, right)
                            cv2.imwrite(thermalImageName, thermal)

                        if (display):
                            cv2.imshow('Left Frame',
                                       imutils.resize(left, width=640))
                            cv2.imshow('Right Frame',
                                       imutils.resize(right, width=640))
                            cv2.imshow('Thermal Frame',
                                       imutils.resize(thermal, width=640))
                    else:
                        print("Thermal Queue not full")
                        print("Thermal Queue Size: {}".format(
                            qThermal.qsize()))
                    #

                    if cv2.waitKey(1) & 0xFF == ord('q'):
                        break

            finally:
                libuvc.uvc_stop_streaming(devh)

            capLeft.release()
            capRight.release()
            cv2.destroyAllWindows()
            cr.printLabel("MINTS done")

        finally:
            libuvc.uvc_unref_device(dev)
    finally:
        libuvc.uvc_exit(ctx)

    cr.printMINTS("fevSen")
Example #3
0
#
#  Step 11 : Obtaining a Overlay Params

import cv2
import pickle
import numpy as np
from matplotlib import pyplot as plt
import os
from scipy.io import loadmat
import math
import pickle
import datetime
import h5py
from mintsJetson import camReader as cr

cr.printMINTS("Fever Sensor Calibration")

cr.printLabel("User Defined Variables")
loadName1 = 'dataFiles/DF_010_overlayParams_jetson002_Set1_2020_04_11_17_37_56.mat'
loadName2 = 'dataFiles/DF_007_distanceParams_Jetson002_Set1_2020_04_11_17_02_47.mat'

dateTime = datetime.datetime.now()
horizontalSquares = 8
verticalSquares = 7

jetsonNum = "002"
setNum = "1"

saveName =  "dataFiles/DF_011_overlayParams_Jetson{}_Set{}_{}_{}_{}_{}_{}_{}.p".format(\
                                            jetsonNum,\
                                            setNum,\