def main(): cr.printLabel("Visual Validation") left, distcanceCM, temperatureC = cr.overlayReturn002( leftImageName, rightImageName, thermalImageName, stereoParams, thermalParams, leftMatcher, overlayParams) cr.plotSubplot(left, distcanceCM, temperatureC) cr.printLabel("Gaining Results") resultsCelius = cr.getCurrentFeverSensorInfoCelcius(leftImageName,rightImageName,thermalImageName,\ stereoParams,thermalParams,overlayParams,\ leftMatcher,scalingFactor,coordsIn) resultsFarenheit=cr.getCurrentFeverSensorInfoFarenheit(leftImageName,rightImageName,thermalImageName,\ stereoParams,thermalParams,overlayParams,\ leftMatcher,scalingFactor,coordsIn) cr.printLabel("Printing Results in CM & Celcius:") print(resultsCelius) cr.printLabel("Printing Results in CM & Farenheit:") print(resultsFarenheit)
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")
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 height = 480 frameRate = 30
# # S_003 : Generating Thermal Camera Parametors import math import pickle from scipy.io import loadmat import numpy as np from matplotlib import pyplot as plt import cv2 from mintsJetson import camReader as cr import datetime cr.printMINTS("fevSen") cr.printLabel("User Defined Variables") loadName = 'dataFiles/DF_004_pythonThermalJetson001_Set2_2020_04_02.mat' dateTime = datetime.datetime.now() horizontalSquares = 8 verticalSquares = 7 saveName = "dataFiles/DF_005_thermalParams_Jetson001_{}_{}_{}_{}_{}_{}.p".format(\ str(dateTime.year).zfill(4),\ str(dateTime.month).zfill(2),\ str(dateTime.day).zfill(2),\ str(dateTime.hour).zfill(2),\ str(dateTime.minute).zfill(2),\ str(dateTime.second).zfill(2)\ ) print("Load Name : '{}'".format(loadName)) print("Save Name : '{}'".format(saveName))
# % # *************************************************************************** # # S_003 : Generating Visual Camera Parametors import math import pickle from scipy.io import loadmat import numpy as np from matplotlib import pyplot as plt import cv2 from mintsJetson import camReader as cr import datetime cr.printMINTS("fevSen") cr.printLabel("User Defined Variables") loadName = 'dataFiles/DF_002_pythonVisualJetson002_Set1_2020_04_10_14_07_40.mat' jetsonNum = "002" setNum = "1" dateTime = datetime.datetime.now() horizontalSquares = 8 verticalSquares = 7 saveName = "dataFiles/DF_003_stereoParams_Jetson{}_Set{}_{}_{}_{}_{}_{}_{}.p".format(\ jetsonNum,\ setNum,\ str(dateTime.year).zfill(4),\ str(dateTime.month).zfill(2),\ str(dateTime.day).zfill(2),\
# # S_008 : Saving Image Files for MatLab import cv2 import pickle import numpy as np from matplotlib import pyplot as plt import cv2 from mintsJetson import camReader as cr import datetime from scipy.io import loadmat cr.printMINTS("fevSen") cr.printLabel("User Defined Variables") directory = "/home/teamlary/mintsData/jetson002Set1/" cr.printLabel("Loading Data Files") stereoParams = pickle.load( open("dataFiles/DF_003_stereoParams_Jetson002_Set1_2020_04_10_14_09_01.p", "rb")) thermalParams = pickle.load( open("dataFiles/DF_005_thermalParams_Jetson002_Set1_2020_04_11_16_51_50.p", "rb")) leftAndRightParametors = loadmat( 'dataFiles/DF_002_pythonVisualJetson002_Set1_2020_04_10_14_07_40.mat') imageFileNamesLeft = leftAndRightParametors['imageFileNames1'] imageFileNamesRight = leftAndRightParametors['imageFileNames2'] cr.printLabel("Gaining Stereo File Names from the Matlab Deployment")
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,\ str(dateTime.year).zfill(4),\ str(dateTime.month).zfill(2),\
import imutils import cv2 cr.printMINTS("fevSen") directory = "/home/teamlary/mintsData/jetson002Set1/" sourceLeft = directory + "left/" sourceRight = directory + "right/" destinationLeft = directory + "leftResized/" destinationRight = directory + "rightResized/" resizeWidth = 648 cr.printLabel("Creating Sub Directories") cr.folderCheck(destinationLeft) cr.folderCheck(destinationRight) def resizeAndWrite(source, destination, widthIn): if (os.path.exists(source)): print("Source Path Left : {}".format(source)) print("Destination Path Right : {}".format(destination)) cr.folderCheck(os.path.dirname(destination)) resized = imutils.resize(cv2.imread(source), width=widthIn) print("Writing Resized Image of '{}' to '{}'".format( source, destination)) cv2.imwrite(destination, resized) return True, resized else:
# # Step 012: Stereo Thermal Calibration Jetson 001 import cv2 import pickle import numpy as np from matplotlib import pyplot as plt from scipy.io import loadmat import datetime import os, sys, inspect from os import path import h5py import imutils from mintsJetson import camReader as cr cr.printLabel("Loading Parametors") stereoParams = pickle.load( open("dataFiles/DF_003_stereoParams_Jetson001_2020_04_02_19_05_49.p", "rb")) thermalParams = pickle.load( open("dataFiles/DF_005_thermalParams_Jetson001_2020_04_02_22_55_59.p", "rb")) overlayParams = pickle.load( open("dataFiles/DF_011_overlayParams_Jetson001_2020_04_04_19_19_01.p", "rb")) cr.printLabel("Defining Image Names") thermalImageName = "exampleImages/jetson001_thermal.h5" leftImageName = "exampleImages/jetson001_left.jpg" rightImageName = "exampleImages/jetson001_right.jpg" scalingFactor = 4
cr.printMINTS("fevSen") directory = "/home/teamlary/mintsData/jetson002Set1/" sourceFolder = "/home/teamlary/mintsData/jetson002Set1All/" lookUpFolder = directory +"left/" destinationFolder = directory sourceFolderRight = sourceFolder + "right/" sourceFolderThermal = sourceFolder + "thermal/" destinationFolderRight = destinationFolder + "right/" destinationFolderThermal = destinationFolder + "thermal/" cr.printLabel("Creating Sub Directories") cr.folderCheck(destinationFolderRight) cr.folderCheck(destinationFolderThermal) print("Listing all files") if os.path.isdir(lookUpFolder): print("Available Files in '{}':".format(lookUpFolder)) for fileName in sorted(os.listdir(lookUpFolder)): if fileName.endswith(".jpg"): full= lookUpFolder + fileName fileNameCheck = fileName[0:26] # Moving Right Images
# # % For the visual camera calibration utdset0 is used # # % Define images to process import math import pickle from scipy.io import loadmat import numpy as np from matplotlib import pyplot as plt import cv2 from mintsJetson import camReader as cr cr.printMINTS("fevSen") cr.printLabel("Loading Stereo Vision Parametors From Matlab") leftAndRightParametors = loadmat( 'dataFiles/DF_002_pythonVisualJetson001_Set2_2020_04_01_2.mat') allImagePoints = leftAndRightParametors['imagePoints'] leftImagePoints = leftAndRightParametors['leftImagePoints'] rightImagePoints = leftAndRightParametors['rightImagePoints'] imageFileNamesLeft = leftAndRightParametors['imageFileNames1'] imageFileNamesRight = leftAndRightParametors['imageFileNames2'] cr.printLabel("Defining Chekerboard Specifications") horizontalSquares = 8 verticalSquares = 7 horizontalInnerCorners = horizontalSquares - 1 verticalInnerCorners = verticalSquares - 1 scaleFactor = 4
# % For the visual camera calibration utdset0 is used # # % Define images to process import math import pickle from scipy.io import loadmat import numpy as np from matplotlib import pyplot as plt import cv2 from mintsJetson import camReader as cr import datetime cr.printMINTS("fevSen") cr.printLabel("User Defined Variables") loadName = 'dataFiles/DF_002_pythonVisualJetson001_Set2_2020_04_01.mat' dateTime = datetime.datetime.now() horizontalSquares = 8 verticalSquares = 7 saveName = "dataFiles/DF_003_stereoParams_Jetson001_{}_{}_{}_{}_{}_{}.p".format(\ str(dateTime.year).zfill(4),\ str(dateTime.month).zfill(2),\ str(dateTime.day).zfill(2),\ str(dateTime.hour).zfill(2),\ str(dateTime.minute).zfill(2),\ str(dateTime.second).zfill(2)\ ) print("Load Name : '{}'".format(loadName)) print("Save Name : '{}'".format(saveName))
from mintsJetson import camReader as cr print(cv2.__version__) # Loading data from the stereo calibration print("Loading data from the stereo calibration") stereoParams = pickle.load( open("dataFiles/DF_003_stereoParams_Jetson002_Set1_2020_04_10_14_09_01.p", "rb")) leftAndRightParametors = loadmat( 'dataFiles/DF_002_pythonVisualJetson002_Set1_2020_04_10_14_07_40.mat') imageFileNamesLeft = leftAndRightParametors['imageFileNames1'] imageFileNamesRight = leftAndRightParametors['imageFileNames2'] cr.printLabel("Gaining Stereo File Names from the Matlab Deployment") leftFileNames, rightFileNames = cr.mat2PyGetStereoFileNames( imageFileNamesLeft, imageFileNamesRight) distances = np.arange(40, 301, 10).tolist() cr.printLabel("Number of Distcanes Calibrated :{}".format(len(distances))) currentIndex = 23 # rawDistances for jetson001= [1005,925,765,657,572,512,460,418,382,352,\ # 320,307,289,270,256,240,227,220,208,200,\ # 192,182,176,167,160,157,147,144,143\ # ] # rawDistances for jetson001= \ # [1010,944,778,670,583,520,468,422,390,360,\