Example #1
0
def mask_image( im, mask ):
	if mask.depth == 8:
		bim = cv.cvCreateImage( cv.cvSize(mask.width, mask.height), cv.IPL_DEPTH_32F, mask.nChannels )
		cv.cvConvertScale( mask, bim, 1.0/255.0)

	if im.depth == 8:
		newim = cv.cvCreateImage( cv.cvSize(im.width, im.height), cv.IPL_DEPTH_32F, im.nChannels )
		cv.cvConvertScale( im, newim, 1.0/255.0)

		
	print 'newim.depth = ',newim.depth
	print 'newim.nChannels = ',newim.nChannels
	print 'bim.depth = ',bim.depth
	print 'bim.nChannels = ',bim.nChannels
	if newim.nChannels == 3 and newim.depth == 32 and bim.nChannels == 3 and bim.depth == 32:
		outputIm = cv.cvCloneImage( bim )
		cv.cvMul( bim, newim, outputIm, 1 )
		return outputIm
	else:
		print 'oops problem with formats'
		return mask
Example #2
0
def mask_image(im, mask):
    if mask.depth == 8:
        bim = cv.cvCreateImage(cv.cvSize(mask.width, mask.height),
                               cv.IPL_DEPTH_32F, mask.nChannels)
        cv.cvConvertScale(mask, bim, 1.0 / 255.0)

    if im.depth == 8:
        newim = cv.cvCreateImage(cv.cvSize(im.width, im.height),
                                 cv.IPL_DEPTH_32F, im.nChannels)
        cv.cvConvertScale(im, newim, 1.0 / 255.0)

    print 'newim.depth = ', newim.depth
    print 'newim.nChannels = ', newim.nChannels
    print 'bim.depth = ', bim.depth
    print 'bim.nChannels = ', bim.nChannels
    if newim.nChannels == 3 and newim.depth == 32 and bim.nChannels == 3 and bim.depth == 32:
        outputIm = cv.cvCloneImage(bim)
        cv.cvMul(bim, newim, outputIm, 1)
        return outputIm
    else:
        print 'oops problem with formats'
        return mask
Example #3
0
	def _multiply_frames(self,frame1,frame2,scale=1.) :
		cv_mult = cv.cvCreateImage(cv.cvSize(frame1.width,frame1.height),frame1.depth,frame1.nChannels)
		cv.cvMul(frame1,frame2,cv_mult,scale)
		return cv_mult
Example #4
0
    while 1:
        # do forever
        # capture the current image
        frame = highgui.cvQueryFrame(capture)
        highgui.cvShowImage('Originale', frame)

        if frame is None:
            # no image captured... end the processing
            break

        ################   traitement de l'image   ################
        cv.cvCvtColor(frame, frameGray, cv.CV_BGR2GRAY)
        # niveau de gris
        cv.cvSub(frameGray, frameGrayBg, framewithoutbg)
        # soustraction du background
        cv.cvMul(framewithoutbg, framewithoutbg, framemul, get_gain())
        # amplification
        cv.cvSmooth(framemul, framelisser1, cv.CV_BLUR, param_liss[0],
                    param2_liss[0])
        # lissage
        if first == 0:  # "moyenne" sur deux image
            cv.cvAnd(framelisser1, framelisser2, framelisser)
        if first == 1:
            framelisser = cv.cvCloneImage(framelisser1)

        framelisser2 = cv.cvCloneImage(framelisser1)

        cv.cvThreshold(framelisser, frameBin, get_seuil(), float(255),
                       cv.CV_THRESH_BINARY)  # binaristaion de l image

        ################   run detection   ################