coastalimagelib/argusIO.py
def deBayerRawFrameOpenCV(self):

        '''
        deBayers a raw frame utilizing the package opencv
        
        Use this function for debayering into an grayscale
        image output
        
        '''

        im = np.zeros(np.shape(self.raw), dtype='uint8')
        self.imGrayCV = np.zeros(np.shape(self.raw), dtype='uint8')
        imR = np.zeros(np.shape(self.raw), dtype='uint8')
        imB = np.zeros(np.shape(self.raw), dtype='uint8')
        imG = np.zeros(np.shape(self.raw), dtype='uint8')

        if self.nFrames == 1:  # used for limited memory operations
            frame = self.raw
            framecopy = np.uint8(frame)
            rgbArray = cv2.cvtColor(framecopy, cv2.COLOR_BayerGB2BGR)

            imGrayscale = cv2.cvtColor(rgbArray, cv2.COLOR_BGR2GRAY)
            self.imGrayCV[:, :] = np.uint8(imGrayscale)
        elif self.parallel is True:
            import multiprocessing as mp
            pool = mp.Pool(mp.cpu_count() - 1)
            # https://www.machinelearningplus.com/python/parallel-processing-python/
            imGrayscale = pool.starmap_async(cv2.cvtColor, [(np.uint8(self.raw[:,:,ib]), cv2.COLOR_BayerGB2GRAY)
                                                        for ib in range(self.nFrames)]).get()
            pool.close()
            self.imGrayCV = np.array(imGrayscale, dtype=np.uint8)

        else:
            for ib in range(self.nFrames):
                if ib % 20 == 0 and self.verbose==True:
                    print(f'debayering frame {ib}/{self.nFrames}')
                frame = self.raw[:, :, ib]
                framecopy = np.uint8(frame)
                rgbArray = cv2.cvtColor(framecopy, cv2.COLOR_BayerGB2BGR)
                imGrayscale = cv2.cvtColor(rgbArray, cv2.COLOR_BGR2GRAY)

                self.imGrayCV[:, :, ib] = np.uint8(imGrayscale)

        deBayers a raw frame utilizing the package opencv
        
        Use this function for debayering into an grayscale
        image output
        
        
deBayers a raw frame utilizing the package opencv
Use this function for debayering into an grayscale
image output
deBayers a raw frame utilizing the package opencv Use this function for debayering into an grayscale image output
def deBayerRawFrameOpenCV(self):
        im = np.zeros(np.shape(self.raw), dtype='uint8')
        self.imGrayCV = np.zeros(np.shape(self.raw), dtype='uint8')
        imR = np.zeros(np.shape(self.raw), dtype='uint8')
        imB = np.zeros(np.shape(self.raw), dtype='uint8')
        imG = np.zeros(np.shape(self.raw), dtype='uint8')
        if self.nFrames == 1:  
            frame = self.raw
            framecopy = np.uint8(frame)
            rgbArray = cv2.cvtColor(framecopy, cv2.COLOR_BayerGB2BGR)
            imGrayscale = cv2.cvtColor(rgbArray, cv2.COLOR_BGR2GRAY)
            self.imGrayCV[:, :] = np.uint8(imGrayscale)
        elif self.parallel is True:
            import multiprocessing as mp
            pool = mp.Pool(mp.cpu_count() - 1)
            imGrayscale = pool.starmap_async(cv2.cvtColor, [(np.uint8(self.raw[:,:,ib]), cv2.COLOR_BayerGB2GRAY)
                                                        for ib in range(self.nFrames)]).get()
            pool.close()
            self.imGrayCV = np.array(imGrayscale, dtype=np.uint8)
        else:
            for ib in range(self.nFrames):
                if ib % 20 == 0 and self.verbose==True:
                    print(f'debayering frame {ib}/{self.nFrames}')
                frame = self.raw[:, :, ib]
                framecopy = np.uint8(frame)
                rgbArray = cv2.cvtColor(framecopy, cv2.COLOR_BayerGB2BGR)
                imGrayscale = cv2.cvtColor(rgbArray, cv2.COLOR_BGR2GRAY)
                self.imGrayCV[:, :, ib] = np.uint8(imGrayscale)
def deBayerRawFrameOpenCV ( self ) : im = np . zeros ( np . shape ( self . raw ) , dtype = 'uint8' ) self . imGrayCV = np . zeros ( np . shape ( self . raw ) , dtype = 'uint8' ) imR = np . zeros ( np . shape ( self . raw ) , dtype = 'uint8' ) imB = np . zeros ( np . shape ( self . raw ) , dtype = 'uint8' ) imG = np . zeros ( np . shape ( self . raw ) , dtype = 'uint8' ) if self . nFrames == 1 : frame = self . raw framecopy = np . uint8 ( frame ) rgbArray = cv2 . cvtColor ( framecopy , cv2 . COLOR_BayerGB2BGR ) imGrayscale = cv2 . cvtColor ( rgbArray , cv2 . COLOR_BGR2GRAY ) self . imGrayCV [ : , : ] = np . uint8 ( imGrayscale ) elif self . parallel is True : import multiprocessing as mp pool = mp . Pool ( mp . cpu_count ( ) - 1 ) imGrayscale = pool . starmap_async ( cv2 . cvtColor , [ ( np . uint8 ( self . raw [ : , : , ib ] ) , cv2 . COLOR_BayerGB2GRAY ) for ib in range ( self . nFrames ) ] ) . get ( ) pool . close ( ) self . imGrayCV = np . array ( imGrayscale , dtype = np . uint8 ) else : for ib in range ( self . nFrames ) : if ib % 20 == 0 and self . verbose == True : print ( f'debayering frame {ib}/{self.nFrames}' ) frame = self . raw [ : , : , ib ] framecopy = np . uint8 ( frame ) rgbArray = cv2 . cvtColor ( framecopy , cv2 . COLOR_BayerGB2BGR ) imGrayscale = cv2 . cvtColor ( rgbArray , cv2 . COLOR_BGR2GRAY ) self . imGrayCV [ : , : , ib ] = np . uint8 ( imGrayscale )
deBayers a raw frame utilizing the package opencv
Use this function for debayering into an grayscale
image output
deBayers a raw frame utilizing the package opencv Use this function for debayering into an grayscale image output
'''
        deBayers a raw frame utilizing the package opencv
        
        Use this function for debayering into an grayscale
        image output
        
        ''' # used for limited memory operations # https://www.machinelearningplus.com/python/parallel-processing-python/
self