Subtracting Background From Image using Opencv in Python
replace  foreground = np.absolute(frame - background)
with foreground = cv2.absdiff(frame, background)
The following program displays 'foreground' completely black and not 'frame'. I also checked that all the values in 'frame' is equal to the values in 'foreground'.
They have same channels,data type etc.
I am using python 2.7.6 and OpenCV version 2.4.8

    import cv2
    import numpy as np

    def subtractBackground(frame,background):
        foreground = np.absolute(frame - background)
        foreground = foreground >= 0
        foreground = foreground.astype(int)
        foreground = foreground * frame
        cv2.imshow("foreground",foreground)
        return foreground

    def main():
        cap = cv2.VideoCapture(0)
        dump,background = cap.read()

        while cap.isOpened():
            dump,frame = cap.read()
            frameCopy = subtractBackground(frame,background)
            cv2.imshow('Live',frame)
            k = cv2.waitKey(10)
            if k == 32:
                break

    if __name__ == '__main__':
        main()