#! /usr/bin/env python # -*- coding: utf-8 -*- import numpy as np import cv2 width = 320 height = 240 margin = 50 cap = cv2.VideoCapture(0) # Let us resize the video to width x height cap.set(3,width) cap.set(4,height) # Processing starts while(True): is_ok, frame = cap.read() subframe = frame[margin:(height-margin), # row number on first axis. margin:(width-margin), # column number on second axis. :] # channel number (R,G or B) on third axis. # subframe = 255 - subframe # ask why this is wrong... subframe[...] = 255 - subframe cv2.imshow('display',frame) if cv2.waitKey(1) & 0xFF == 27: #27 is the ascii for escape break # When everything done, release the capture cap.release() cv2.destroyAllWindows()