main.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:Computer-Vision 作者: PratikRamdasi 项目源码 文件源码
def initialFraming(self,path):
        global cap
        global success
        global frame

        sampleIndex=0
        cap = cv2.VideoCapture(path)
        success,frame=cap.read(cv.CV_IMWRITE_JPEG_QUALITY)       
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        gray = cv2.GaussianBlur(gray, (21, 21), 0)
        height,width = gray.shape[:2]
        print "Dimension of the image is: ",height, width, (height*width)

        samples = np.array([[0 for x in range(0,self.numberOfSamples)] for x in range(0,(height*width))])

        tempArray = np.reshape(gray,(height*width)).T

        samples[:,sampleIndex]= np.copy(tempArray)
        sampleIndex+=1

        while (success and sampleIndex!=(self.numberOfSamples)):
            success,frame = cap.read(cv.CV_IMWRITE_JPEG_QUALITY)
            gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            gray = cv2.GaussianBlur(gray, (21, 21), 0)
            tempArray = (np.reshape(gray,(height*width))).T
            samples[:,sampleIndex]= np.copy(tempArray)
            sampleIndex+=1

        return samples
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号