├── beam images ├── beam_fast_2 │ ├── frame_rate_13107over32768img000.bmp │ ├── frame_rate_13107over32768img000.jpeg │ ├── frame_rate_13107over65536img000.bmp │ ├── frame_rate_13107over65536img001.bmp │ ├── frame_rate_13107over65536img002.bmp │ ├── frame_rate_13107over65536img003.bmp │ ├── frame_rate_13107over65536img004.bmp │ ├── frame_rate_13107over65536img005.bmp │ ├── frame_rate_13107over65536img006.bmp │ ├── frame_rate_13107over65536img007.bmp │ ├── frame_rate_13107over65536img008.bmp │ ├── frame_rate_13107over65536img009.bmp │ ├── frame_rate_13107over65536img010.bmp │ ├── frame_rate_13107over65536img011.bmp │ ├── frame_rate_13107over65536img012.bmp │ ├── frame_rate_13107over65536img013.bmp │ ├── frame_rate_13107over65536img013.jpeg │ ├── frame_rate_13107over65536img014.bmp │ ├── frame_rate_13107over65536img015.bmp │ ├── frame_rate_13107over65536img016.bmp │ ├── frame_rate_13107over65536img016.jpeg │ ├── frame_rate_13107over65536img017.bmp │ ├── frame_rate_13107over65536img018.bmp │ ├── frame_rate_13107over65536img019.bmp │ └── frame_rate_13107over65536img019.jpeg ├── beam_thermal │ ├── frame_rate_13107over65536img000.bmp │ ├── frame_rate_13107over65536img001.bmp │ ├── frame_rate_13107over65536img002.bmp │ ├── frame_rate_13107over65536img003.bmp │ ├── frame_rate_13107over65536img004.bmp │ ├── frame_rate_13107over65536img005.bmp │ ├── frame_rate_13107over65536img006.bmp │ ├── frame_rate_13107over65536img007.bmp │ ├── frame_rate_13107over65536img008.bmp │ ├── frame_rate_13107over65536img009.bmp │ ├── frame_rate_13107over65536img010.bmp │ └── frame_rate_13107over65536img011.bmp └── no_beam │ ├── frame_rate_13107over65536img000.bmp │ ├── frame_rate_13107over65536img001.bmp │ ├── frame_rate_13107over65536img002.bmp │ ├── frame_rate_13107over65536img003.bmp │ ├── frame_rate_13107over65536img004.bmp │ ├── frame_rate_13107over65536img005.bmp │ ├── frame_rate_13107over65536img006.bmp │ ├── frame_rate_13107over65536img007.bmp │ └── frame_rate_13107over65536img008.bmp ├── counter.py ├── documentation.docx ├── install.sh ├── iss downloads ├── Radiation_20160307_095242.txt ├── Radiation_faulty.bmp ├── Radiation_start000.bmp ├── Radiation_start001.bmp ├── Radiation_start002.bmp └── Radiation_start003.bmp ├── pixcheck.py ├── run.py ├── show.py └── start.sh /beam images/beam_fast_2/frame_rate_13107over32768img000.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over32768img000.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over32768img000.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over32768img000.jpeg -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img000.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img000.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img001.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img001.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img002.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img002.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img003.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img003.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img004.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img004.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img005.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img005.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img006.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img006.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img007.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img007.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img008.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img008.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img009.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img009.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img010.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img010.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img011.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img011.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img012.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img012.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img013.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img013.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img013.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img013.jpeg -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img014.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img014.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img015.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img015.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img016.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img016.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img016.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img016.jpeg -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img017.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img017.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img018.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img018.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img019.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img019.bmp -------------------------------------------------------------------------------- /beam images/beam_fast_2/frame_rate_13107over65536img019.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_fast_2/frame_rate_13107over65536img019.jpeg -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img000.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img000.bmp -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img001.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img001.bmp -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img002.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img002.bmp -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img003.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img003.bmp -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img004.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img004.bmp -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img005.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img005.bmp -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img006.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img006.bmp -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img007.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img007.bmp -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img008.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img008.bmp -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img009.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img009.bmp -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img010.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img010.bmp -------------------------------------------------------------------------------- /beam images/beam_thermal/frame_rate_13107over65536img011.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/beam_thermal/frame_rate_13107over65536img011.bmp -------------------------------------------------------------------------------- /beam images/no_beam/frame_rate_13107over65536img000.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/no_beam/frame_rate_13107over65536img000.bmp -------------------------------------------------------------------------------- /beam images/no_beam/frame_rate_13107over65536img001.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/no_beam/frame_rate_13107over65536img001.bmp -------------------------------------------------------------------------------- /beam images/no_beam/frame_rate_13107over65536img002.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/no_beam/frame_rate_13107over65536img002.bmp -------------------------------------------------------------------------------- /beam images/no_beam/frame_rate_13107over65536img003.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/no_beam/frame_rate_13107over65536img003.bmp -------------------------------------------------------------------------------- /beam images/no_beam/frame_rate_13107over65536img004.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/no_beam/frame_rate_13107over65536img004.bmp -------------------------------------------------------------------------------- /beam images/no_beam/frame_rate_13107over65536img005.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/no_beam/frame_rate_13107over65536img005.bmp -------------------------------------------------------------------------------- /beam images/no_beam/frame_rate_13107over65536img006.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/no_beam/frame_rate_13107over65536img006.bmp -------------------------------------------------------------------------------- /beam images/no_beam/frame_rate_13107over65536img007.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/no_beam/frame_rate_13107over65536img007.bmp -------------------------------------------------------------------------------- /beam images/no_beam/frame_rate_13107over65536img008.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/beam images/no_beam/frame_rate_13107over65536img008.bmp -------------------------------------------------------------------------------- /counter.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Name: Ultimate object detector 3 | ''' 4 | import cv2, time 5 | #import pixcheck as pxc 6 | 7 | def giveCount(img, low_threshold, high_threshold): 8 | #Faulty pixel check 9 | start = time.time() 10 | #faulty = pxc.pixcheck(img,img,img)#Change to check last 3 imgs 11 | #img = cv2.subtract(img,faulty) 12 | 13 | #Object count in faulty 14 | #fimgblur = cv2.GaussianBlur(faulty, (3,3), 0) 15 | #CHECK WHAT HAPPENS IF DON'T THRESHOLD 16 | #fret1, fthresh = cv2.threshold(fimgblur,low_threshold,255,3) #Needs to autoThreshold 17 | #fimage, fcontours, fhierachy = cv2.findContours(fthresh, cv2.RETR_LIST,cv2.CHAIN_APPROX_NONE) 18 | #print("Faulty objects: "+str(len(fcontours))) 19 | 20 | #blur (to minimise noise) 21 | imgblur = cv2.GaussianBlur(img, (3,3), 0) #Gaussian (s = 0 means auto) 22 | #imgblur = cv2.bilateralFilter(img, 3, sigmaColor,25) #Bilateral 23 | end = time.time() 24 | blurtime = end-start 25 | print("Blur time: "+str(blurtime)) 26 | 27 | start = time.time() 28 | #Don't think thresholding is necessary with Canny!! 29 | #ret1, thresh = cv2.threshold(imgblur,low_threshold,255,3) 30 | #ret,thresh = cv2.adaptiveThreshold(imgblur,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,3,0) 31 | end = time.time() 32 | print("1st Threshold time: "+str(end-start)+"s") 33 | 34 | start = time.time() 35 | edges = cv2.Canny(imgblur,low_threshold,high_threshold) 36 | end = time.time() 37 | print("Canny time: "+str(end-start)+"s") 38 | image, contours, hierachy = cv2.findContours(edges, cv2.RETR_LIST,cv2.CHAIN_APPROX_NONE) 39 | count = len(contours) 40 | print("Objects detected: "+str(len(contours))) 41 | return count 42 | 43 | #cv2.imshow("preview",out) 44 | 45 | def main(): 46 | low_threshold = 0 47 | 48 | try: 49 | opts, args = getopt.getopt(sys.argv[1:], "i:", ["image="]) 50 | except getopt.GetoptError as err: 51 | print(err) 52 | sys.exit(2) 53 | src = "" 54 | for o, a in opts: 55 | if o in ("-i","--image"): 56 | src = a 57 | else: 58 | assert False, "unhandled option" 59 | global img 60 | img = cv2.imread(src,cv2.IMREAD_GRAYSCALE) 61 | cv2.namedWindow("preview",cv2.WINDOW_NORMAL) 62 | cv2.imshow("preview",img) 63 | cv2.createTrackbar("Min threshold", "preview", low_threshold, 255, findContours) 64 | #cv2.createTrackbar("Standard dev", "preview", std, 2, findContours) 65 | #cv2.createTrackbar("sigmaColor", "preview", sigmaColor, 100, findContours) 66 | cv2.waitKey(0) 67 | if __name__ == "__main__": 68 | print ("loaded libraries") 69 | main() 70 | -------------------------------------------------------------------------------- /documentation.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/documentation.docx -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt-get update 3 | sudo apt-get install python3-picamera -------------------------------------------------------------------------------- /iss downloads/Radiation_faulty.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/iss downloads/Radiation_faulty.bmp -------------------------------------------------------------------------------- /iss downloads/Radiation_start000.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/iss downloads/Radiation_start000.bmp -------------------------------------------------------------------------------- /iss downloads/Radiation_start001.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/iss downloads/Radiation_start001.bmp -------------------------------------------------------------------------------- /iss downloads/Radiation_start002.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/iss downloads/Radiation_start002.bmp -------------------------------------------------------------------------------- /iss downloads/Radiation_start003.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astro-pi/radiation/9c4f14cef27d28d1579652e405c93c1c633c1556/iss downloads/Radiation_start003.bmp -------------------------------------------------------------------------------- /pixcheck.py: -------------------------------------------------------------------------------- 1 | import cv2, sys, math, numpy 2 | 3 | def pixcheck(imgs): 4 | global cv2 5 | if len(imgs)>1: 6 | #Find overlap between first two images 7 | overlap = cv2.bitwise_and(imgs[0],imgs[1]) 8 | imgs.pop(0) 9 | imgs.pop(0) 10 | if(len(imgs)>0): 11 | for img in imgs: 12 | overlap = cv2.bitwise_and(overlap,img) 13 | return overlap 14 | else: 15 | #Not enough images 16 | return False 17 | -------------------------------------------------------------------------------- /run.py: -------------------------------------------------------------------------------- 1 | import sys, getopt, time, picamera.array, cv2, os, numpy, errno 2 | import counter, pixcheck, show 3 | #Set some variables: 4 | 5 | #Get options 6 | try: 7 | opts, args = getopt.getopt(sys.argv[1:], "n:", ["name="]) 8 | except getopt.GetoptError as err: 9 | print(err) 10 | sys.exit(2) 11 | 12 | for o, a in opts: 13 | if o in("-n","--name"): 14 | name = a 15 | else: 16 | assert False, "unhandled option" 17 | #Start camera 18 | with picamera.PiCamera() as camera: 19 | #LED automatically turns on, this turns it off 20 | camera.led = False 21 | #display a big c on screen! 22 | show.calibrateMessage() 23 | framerate = 1 24 | 25 | time.sleep(1) # Allows automatic gain control to settle 26 | #Now fix auto white balance 27 | camera.awb_mode = "off" 28 | g = camera.awb_gains 29 | camera.awb_gains = g 30 | camera.framerate = framerate 31 | camera.shutter_speed = int(1000000/camera.framerate) #Shutter speed is in microseconds 32 | camera.exposure_mode = "off" 33 | camera.iso = 800 34 | 35 | #take 4 startup pictures for faulty pixel check and analysis on ground later 36 | 37 | filename=name+"/" 38 | try: 39 | os.makedirs(os.path.dirname(filename), exist_ok=True) #Sometimes this doesn't work find out why!! 40 | except OSError as exception: 41 | if exception.errno != errno.EEXIST: 42 | raise 43 | #Saves in bmp format 44 | camera.capture_sequence([filename+'start%03d.bmp' % i for i in range(4)], format="bmp") 45 | i1 = cv2.imread(name+"/start000.bmp",cv2.IMREAD_GRAYSCALE) 46 | i2 = cv2.imread(name+"/start001.bmp",cv2.IMREAD_GRAYSCALE) 47 | i3 = cv2.imread(name+"/start002.bmp",cv2.IMREAD_GRAYSCALE) 48 | i4 = cv2.imread(name+"/start003.bmp",cv2.IMREAD_GRAYSCALE) 49 | gallery = [i1,i2,i3,i4] 50 | faulty = pixcheck.pixcheck(list(gallery)) 51 | cv2.imwrite(name+"/faulty.bmp",faulty) 52 | #Start stream 53 | with picamera.array.PiRGBArray(camera) as stream: 54 | i = 0 55 | while True: 56 | #Capture 57 | camera.capture(stream, "rgb") 58 | img=stream.array 59 | #Convert to intensity 60 | grey = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) 61 | 62 | #Remove faulty pixels 63 | start = time.time() 64 | #Load images cached 65 | gallery.append(grey) 66 | if (len(gallery) > 4): 67 | gallery.pop(0) 68 | faulty = pixcheck.pixcheck(list(gallery)) 69 | subtracted = numpy.count_nonzero(faulty) 70 | print("Subtracted pixels: "+str(subtracted)) 71 | #save this 72 | cv2.imwrite(name+"/faulty.bmp",faulty) 73 | end= time.time() 74 | print("Faulty/noisy pixel check time: "+str(end-start)) 75 | 76 | #find objects 77 | high_threshold = 100 78 | low_threshold = 5 79 | counts = counter.giveCount(img,low_threshold,high_threshold) 80 | rate = counts*framerate 81 | print("Rate: "+str(rate)) 82 | show.draw(rate,subtracted) 83 | 84 | print ("Img "+str(i)) 85 | i+=1 86 | stream.seek(0) 87 | stream.truncate() -------------------------------------------------------------------------------- /show.py: -------------------------------------------------------------------------------- 1 | from astro_pi import AstroPi 2 | ap = AstroPi() 3 | 4 | def draw(rate,subtracted): 5 | ap.show_message(str(rate), scroll_speed=1, text_colour=[255,0,0]) # red for count rate 6 | ap.show_message(str(subtracted), scroll_speed=1, text_colour=[0,0,255]) #blue for faulty/noisy pixels 7 | def calibrateMessage(): 8 | ap.show_letter("C") -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo python3 run.py -n Radiationpi --------------------------------------------------------------------------------