[Tutor] Error in get pixel value in coordinate (x, y) using getPixel(x, y)
Whees Northbee
ch.de2.2309 at gmail.com
Mon Aug 18 17:44:02 CEST 2014
I'm so sorry for late reply, my laptop broken, the code actually I already
put in thread before so I'll copy to here..
I don't know how to get pixel, I just searched and many link using
'getPixel' to get value of pixel..
I know color frame using 3 channel B G R to get pixel, but I just want to
get pixel value in 1 channel, they said I need to use video in gray scale,
and I already convert my video to gray scale
Here's the code:
cap =cv2.VideoCapture("c:\Users\Shiloh\Videos\AVI\MOV_5675.avi")
width =cap.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)
height =cap.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)
NUM_SAMPLES =20
RADIUS =20
MIN_MATCHES =2
SUBSAMPLE_FACTOR =16
c_xoff= [-1, 0, 1, -1, 1, -1, 0, 1, 0]
c_yoff= [-1, 0, 1, -1, 1, -1, 0, 1, 0]
while(1):
#Assign space and init
m_samples=[]
#height, width, depth=cap.shape
c_black=np.zeros( (height,width), dtype=np.uint8)
for i in range(0,NUM_SAMPLES,1):
m_samples.append(c_black)
m_mask=np.zeros( (width,height), dtype=np.uint8)
m_foregroundMathCount=np.zeros( (width,height), dtype=np.uint8)
# Capture frame-by-frame
ret, frame = cap.read()
#Init model from first frame
for i in range(0,width,1):
for j in range(0,height,1):
for k in range(0,NUM_SAMPLES,1):
random=np.random.randint(0,9)
row=i+c_yoff[random]
if(row<0):
row=0
if(row>=width):
row=width-1
col=j+c_xoff[random]
if(col<0):
col=0
if(col>=height):
col=height-1
m_samples[k][i][j]=getPixel(frame,row,col)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140818/5f138021/attachment.html>
More information about the Tutor
mailing list