2015-06-29 07:01:10 -0500 received badge ● Self-Learner (source) 2015-06-28 11:18:42 -0500 answered a question What method used in OpenCV to get initial mean and covariance in command cv2.BackgroundSubtractorMOG The initialization for mean and covariance for each Gaussian distribution is 0 as told by the author in line 124 2015-06-28 11:16:06 -0500 answered a question what the use of nmixtures, nchannels in bgmodel.create from bgfg_gaussmix.cpp line 123? I'm so stupid not to understand the comment from the author, so here my explanation.. We want to clustering pixel value at each coordinate (x,y) with mixture of Gaussian, we know that Gaussian distribution have 2 main parameter which is mean, and covariance/variance, and in background subtraction we classify the Gaussian distribution which is foreground or background first by sorting the distributions by weight/(covariance or variance) from the highest, and then sum the weight from the sorting Gaussian before which larger than some threshold (T). For example: we use RGB color space. As I told before, we need mean, covariance, and weight/covariance for each Gaussian distribution.. So we need 3 for save each mean (because it's RGB not grayscale), 3 for save each variance, and 1 for save each weight, 1 for save each weight/covariance ratio, so the total things we need to save for each Gaussian distribution =3+3+1+1=8 that's where the equation (2+2*nchannel) come from.. 2015-06-28 10:44:20 -0500 commented answer Can cv2.dilate using with even kernel like 2x2 or 4x4? I can understand your explanation very well, thank you so much for explanation and the reference source code.. :) 2015-06-28 05:21:44 -0500 commented answer Can cv2.dilate using with even kernel like 2x2 or 4x4? @LBerger, can I ask the last question? Is there maximum value for parameter iterations? 2015-06-28 04:27:27 -0500 commented answer Can cv2.dilate using with even kernel like 2x2 or 4x4? @LBerger ahh.. Thanks for helping me.. I understand now... :) 2015-06-27 10:34:08 -0500 commented answer Can cv2.dilate using with even kernel like 2x2 or 4x4? @LBerger I'm sorry there is mistake when I writing the code, it's giving different result now, but I'm still confuse the anchor x,y value. If default value=(-1,-1) and I use kernel 2x2 so the anchor x,y=1, so it's mean the origin is in bottom right for kernel 2x2 isn't it? 2015-06-27 01:55:33 -0500 commented answer Can cv2.dilate using with even kernel like 2x2 or 4x4? I already try it, but the kernel 2x2 and 3x3 give result the same image, and where opencv put the origin of structure element if kernel 2x2? 2015-06-26 14:14:41 -0500 asked a question Can cv2.dilate using with even kernel like 2x2 or 4x4? Is that possible doing dilation with even kernel in cv2.dilate? 2015-06-13 11:30:18 -0500 asked a question What the mean of - sign in dst[x]=(uchar)(-(khit>=kForeground)); from bgfg_gaussmix.cpp? Hi I want to ask what they mean to put - sign in command dst[x]=(uchar)(-(khit>=kForeground)); and what they want to put in the fgmask? The second command in another conditional statement is more cleardst[x]=(uchar)(kHit<0||kHit>=kForeground?255:0); I fully understand they want to put pixel=255 if kHit<0||kHit>=kForeground is True and pixel=0 if condition is False.. Please help me 2015-06-10 12:18:41 -0500 asked a question what the use of nmixtures, nchannels in bgmodel.create from bgfg_gaussmix.cpp line 123? Hi I've problem to understand why there so many size parameter in bgmodel.create( 1, frameSize.height*frameSize.width*nmixtures*(2 + 2*nchannels), CV_32F ); from bgfg_gaussmix.cpp line 123? Why put nmixtures, and (2+2*channels)? And how they clustering the pixel value like how they get mean and covariance for each Gaussian distribution, it's seems the clustering program is not there.. 2015-05-26 10:15:02 -0500 commented question What method used in OpenCV to get initial mean and covariance in command cv2.BackgroundSubtractorMOG thanks for the info, I'll read it.. 2015-05-26 07:39:44 -0500 commented question What method used in OpenCV to get initial mean and covariance in command cv2.BackgroundSubtractorMOG But how? Can you explain to me? 2015-05-26 05:41:29 -0500 asked a question What method used in OpenCV to get initial mean and covariance in command cv2.BackgroundSubtractorMOG Hi, I want to know what method using for get initial mean and covariance in command cv2.BackgroundSubtractorMOG.. I'm read the c++ program from here but I don't see how they get initial mean and covariance for each Gaussian distribution, and what this command bgmodel.create( 1, frameSize.height * frameSize.width * nmixtures * (2 + 2 * nchannels), CV_32F ); used for? And in KaewTraKulPong Bowden paper "An Improved Adaptive Background Mixture Model for Real-time Tracking with Shadow Detection" they have equation for L recent window, I didn't find code for update equation using L recent window, did the dev used it? 2015-05-05 09:56:30 -0500 asked a question What is the use of parameter history in BackgroundSubtractionMOG? What is actually the history parameter in BackgroundSubtractionMOG use for? I tried change it, but it's looks nothing happen.. 2015-03-09 07:28:07 -0500 commented answer where I can find source code of cv2.BackgroundSubtractorMOG? thank you so much for fast response 2015-03-09 07:11:03 -0500 asked a question where I can find source code of cv2.BackgroundSubtractorMOG? Hello, where I can find the source code of cv2.BackgroundSubtractorMOG? I already search but only find background subtractor MOG2... 2015-01-18 12:47:54 -0500 asked a question How I can count bounding boxes in each frame? Hello, I need to know how I can count for bounding boxes in each frame? I need to know the total bounding boxes, so I know when I need to add new object to be tracking, when total bounding boxes in current frame > total bounding boxes in previous frame I already try with store centroid coordinate (cx,cy) into a list: import cv2 import numpy as np bgsMOG = cv2.BackgroundSubtractorMOG(50,3,0.8) cap = cv2.VideoCapture("d:\\MOV_5702.avi") a = [] if cap: while True: ret, frame = cap.read() if ret: fgmask = bgsMOG.apply(frame, None, 0.99) contours, hierarchy = cv2.findContours(fgmask, cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE) cv2.drawContours(frame,contours,-1,(0,255,0),cv2.cv.CV_FILLED,32) try: hierarchy = hierarchy except: hierarchy = [] for contour, hier in zip(contours, hierarchy): (x,y,w,h) = cv2.boundingRect(contour) if w > 20 and h > 20: cv2.rectangle(frame, (x,y), (x+w,y+h), (180,0,0), 1) (x,y,w,h) = cv2.boundingRect(contour) x1=w/2 y1=h/2 cx=x+x1 cy=y+y1 a.append([cx,cy]) print(len(a)) a=[] cv2.imshow('BGS', fgmask) cv2.imshow('Ori+Bounding Box',frame) key = cv2.waitKey(100) if key == ord('q'): break cap.release() cv2.destroyAllWindows()  But the result always 1.. 2015-01-10 05:15:08 -0500 received badge ● Enthusiast 2015-01-01 00:19:22 -0500 commented question How to find pdf from color histogram and how to play the next frame? Isn't convert the histogram (frequency counts) to pdf (probability) is by integrate the histogram? In camshift demo part def show_hist(self) I don't see the command to make the pdf... 2014-12-29 23:33:41 -0500 commented question How to find pdf from color histogram and how to play the next frame? I already edit the program so it can play the next frame, but it's play the video slowly and everytime I want to close the plot it's always error.. The error is "Runtime Error Program: C:\Python27\pythonw.exe This application has requested the Runtime to terminate it in an unusual way".. How I can fix these? 2014-12-29 03:50:49 -0500 asked a question How to find pdf from color histogram and how to play the next frame? I want to apply the particle filter for tracking.. My friend said that I need to find the pdf of color histogram of the video first as a model state.. I already try with these code to show the plot import cv2 import matplotlib.pyplot as plt from matplotlib.pylab import subplots bgsMOG = cv2.BackgroundSubtractorMOG2() cap = cv2.VideoCapture("d:\MOV_5702.avi") color=('b','g','r') if cap: while True: ret, frame = cap.read() for i,col in enumerate(color): hist = cv2.calcHist([frame],[i],None,,[0,256]) plt.plot(hist,color=col) plt.xlim([0,256]) plt.ion() plt.draw() if ret: gfmask1=cv2.medianBlur(frame,3) fgmask = bgsMOG.apply(gfmask1, None, 0.01) cv2.imshow('Output', frame) key = cv2.waitKey(1) if key == ord('q'): break cap.release() cv2.destroyAllWindows()  My question is: In the paper I read there's only 1 pdf plot, is bgr histogram produce 1 pdf? If yes, how I can do that? If no, am I just used one channel from bgr? The code won't play the next frame, how I can fix it? 2014-12-09 14:02:13 -0500 marked best answer Error in train cascade, is it caused by my .vec file? Hello, this is my first time using opencv... I installed opencv version 2.4.3.. I want to make car detection... I collected positive images 1100 from video with variation size (grayscale and color), and 2035 for negative images ((grayscale and color)... I am using this command for make samples: The size of .vec file just 2 kb Then I try to training using cascade with command: And I got these error, "one of arguments value is out of range" Can you tell me, is there something mistake I made during make .vec file or my cascade command is wrong? My positive description is: And this is the result of re-command training.. 2014-08-06 13:49:58 -0500 asked a question What command in python sample[i].at(x,y)? I want to store each pixel from image(x,y) to variable samples[i] to make model for x in range(0,width,1): for y in range(0,height,1): for i in range(0,NUMBER_SAMPLES,1): random=numpy.random.randint(0,9) row=x+cy[random] if(row<0): row=0 if(row>=width): row=width-1 col=y+cx[random] if(col<0): col=0 if(col>=height): col=height-1 " "=getPixel(cap,row,col)  The " " is jagged array (array in array) where I want to save each pixel, from here:  sample=[] height, width, depth=cap.shape c_black=np.zeros( (height,width), dtype=np.uint8) for i in range(0,NUMBER_SAMPLES,1): sample.append(c_black)  I know in c there's command like sample[i].at(x,y), what in python? 2014-08-02 06:55:10 -0500 commented question how to call vibe in python? @berak what images, you mean numpy array of next frames? and do you mean about indexing of numpy array? I'm so sorry, I'm really newbie in image processing.. 2014-08-02 05:50:59 -0500 commented question how to call vibe in python? @berak, uhm sorry disturbing you again but I don't get it how to program to get samples[x][y][index], could you help me? 2014-07-30 06:56:31 -0500 commented question how to call vibe in python? uhm @berak, I want to ask again.. there code in the link "distance = getEuclideanDist(image[x][y], samples[x][y][index]);" where samples[x][y] is background samples, doesn't we used bgs algorithm like vibe to find background sample so we can know foreground? Do I need implemented like mog to get background model and used it to vibe? 2014-07-30 00:46:09 -0500 commented question how to call vibe in python? thanks @berak, I'll try it... 2014-07-30 00:29:18 -0500 commented question how to call vibe in python? I can't use gpu, my laptop not compatible.. any other bgs algorithm like vibe one?? I need to handle the winding trees.. 2014-07-29 13:02:57 -0500 asked a question how to call vibe in python? I want to detect vehicle and I got problem with winding trees.. I tried MOG and MOG2, not so much satisfy with the result, and I found video example of vibe that can reduce false foreground detection.. I search in opencv documentation but only for c++, any other way to call it in python? 2014-07-29 05:07:49 -0500 commented question Mp4 reading I had same problem before, have you try install ffmpeg or copy all file in c:\opencv\sources\3rdparty\ffmpeg to c:\python? 2014-07-24 14:16:02 -0500 asked a question Question about numPos, S in traincascade, and hard negative I read the thread about numPos here, and I got a little bit confused, I know it soo long explanation but please help me if I wrong.. numPos isn't the total of positive samples I have, but some of it.. It must be lower, if it equal can make error such insufficient new positive samples.. so let's begin in training stage, I assuming: minHitRate=0.9 numStages =2  stage 0: start -> numPos finish -> minimum : 0.9*numPos recognize as positive I called it numPos0 assuming: 0.1*numPos recognize as negative, or background  stage 1: start-> So in this case to get a training set of positive samples for the 1-stage training we have to select (1 - minHitRate) * numPose new samples from vec-file that are recognized as positive by the cascade with 0-stage only. While the selection, some new positive samples from vec-file can be recognized as background right away by the current cascade and we skip such samples. I assuming: (1-0.9)*numPos0->0.1*numPos0 which equal with 0.09*numPos So the 0.91*numPos is getting from new positive sample (unused before) from vec file  The count of skipped sample depends on your vec-file (how different samples are in it) and other training parameters. By analogy, for each i-stage training (i=1,..numStages-1) in the worse case we have to select (1 - minHitRate) * numPose new positive samples and several positive samples will be skipped in the process. Skipped positive samples: 0.1*[(0.1*numPos0)+(0.91*numPos)] -> 0.01*numPos0+0.091*numPos  So numPos need for stage-1 is 0.1*numPos0+0.91*numPos-0.01*numPos0-0.091*numPos -> 0.99*numPos0+0.819*numPos  finish-> 0.9*numPos -> 0.9*[(0.99*numPos0)+(0.819*numPos)] ,I called it numPos1  my question: Am I wrong in something?? In stage-2 for the start, is it (1-0.9)*numPos1? Am I right and understand about the skipped file? I want ask about hard negative what I already read, that I need to crop and resize the negative images as size of my windows classifier, and I just need to re-training it again?? If I finish and re-training it again, will the result better? I'm so sorry if my explanation bad, and my bad grammar.. 2014-07-24 12:11:21 -0500 commented question How I can create samples using opencv 2.4.9 using command prompt, there's only opencv_createsamples.exe for visual studio? @berak thanks for helping me... 2014-07-24 12:11:01 -0500 commented question How I can create samples using opencv 2.4.9 using command prompt, there's only opencv_createsamples.exe for visual studio? @StevenPuttemans yes, it's just basic command, without maxxangle, maxyangle, maxzangle, and such... 2014-07-24 08:18:54 -0500 received badge ● Supporter (source) 2014-07-24 05:26:35 -0500 commented question How I can create samples using opencv 2.4.9 using command prompt, there's only opencv_createsamples.exe for visual studio? She already collected 1500 positive image which she writed in info.txt, the format like this: 1.bmp 1 10 27 388 215, I need to use opencv_createsamples to make vector file, and how do you make vector file manually?