Created
April 25, 2019 19:12
-
-
Save 5shekel/bd0f87f52ad00c781d7753b0eab4676b to your computer and use it in GitHub Desktop.
multi-spectral imaging system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import time | |
import Adafruit_PCA9685 | |
from pyueye import ueye | |
import ctypes | |
import datetime | |
pwm = Adafruit_PCA9685.PCA9685(address = 0x40) #1st | |
pwm1 = Adafruit_PCA9685.PCA9685(address = 0x41) #2nd | |
pwm2 = Adafruit_PCA9685.PCA9685(address = 0x42) #3rd | |
pwm.set_pwm_freq(1000) | |
pwm1.set_pwm_freq(1000) | |
pwm2.set_pwm_freq(1000) | |
spec = "avo_leaf" #name of speciment | |
led = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31] | |
lux = [900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,930,931] #temporary initial value | |
for x,y in zip(led, lux): | |
if (x < 15): | |
pwm.set_pwm(x,y,0) #led on 1st mux | |
elif ( x>14 and x<32): | |
pwm1.set_pwm(x-16,y,0) #led on 2nd mux | |
elif (x>31 and x<33): | |
pwm2.set_pwm(x-32,y,0) #led on 3rd mux | |
else: | |
print(x) | |
hcam = ueye.HIDS(1) | |
pccmem = ueye.c_mem_p() | |
memID = ueye.c_int() | |
hWnd = ctypes.c_voidp() | |
ueye.is_InitCamera(hcam, hWnd) | |
sensorinfo = ueye.SENSORINFO() | |
ueye.is_GetSensorInfo(hcam, sensorinfo) | |
ueye.is_AllocImageMem(hcam, sensorinfo.nMaxWidth, sensorinfo.nMaxHeight,24, pccmem, memID) | |
ueye.is_SetImageMem(hcam, pccmem, memID) | |
nret = ueye.is_FreezeVideo(hcam, ueye.IS_WAIT) | |
if (nret == 0): | |
print("camera") | |
else: | |
print("____problem!!!____") | |
FileParams = ueye.IMAGE_FILE_PARAMS() | |
FileParams.pwchFileName = spec + "_led_"+str(x+1)+"_cam_"+ datetime.datetime.now().strftime("%s") + ".bmp" | |
FileParams.nFileType = ueye.IS_IMG_BMP | |
FileParams.ppcImageMem = None | |
FileParams.pnImageID = None | |
nret = ueye.is_ImageFile(hcam, ueye.IS_IMAGE_FILE_CMD_SAVE, FileParams, ueye.sizeof(FileParams)) | |
if (nret == 0): | |
print("camera") | |
else: | |
print("____problem!!!____") | |
ueye.is_FreeImageMem(hcam, pccmem, memID) | |
ueye.is_ExitCamera(hcam) | |
if (x < 15): | |
pwm.set_pwm(x,0,0) #led off 1st mux | |
elif ( x>14 and x<32): | |
pwm1.set_pwm(x-16,0,0) #led off 2nd mux | |
elif (x>31 and x<33): | |
pwm2.set_pwm(x-32,0,0) #led off 3rd mux | |
else: | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment