
for pic, contour in enumerate(contours): 
    area = cv2.contourArea(contour) 
    if(area > 300): 
        x, y, w, h = cv2.boundingRect(contour) 
        img = cv2.rectangle(img, (x, y),  
                                    (x + w, y + h),  
                                    (0, 255, 0), 2) 
            
        cv2.putText(img, "Red", (x, y), 
                    cv2.FONT_HERSHEY_SIMPLEX, 1.0, 
                    (0, 255, 0),2)     

contours, hierarchy = cv2.findContours(green_mask, 
                                        cv2.RETR_TREE, 
                                        cv2.CHAIN_APPROX_SIMPLE) 
    
for pic, contour in enumerate(contours): 
    area = cv2.contourArea(contour) 
    if(area > 300): 
        x, y, w, h = cv2.boundingRect(contour) 
        img = cv2.rectangle(img, (x, y),  
                                    (x + w, y + h), 
                                    (0, 255, 0), 2) 
            
        cv2.putText(img, "Green", (x, y), 
                    cv2.FONT_HERSHEY_SIMPLEX,  
                    1.0, (0, 255, 0),2) 

contours, hierarchy = cv2.findContours(blue_mask, 
                                        cv2.RETR_TREE, 
                                        cv2.CHAIN_APPROX_SIMPLE) 
for pic, contour in enumerate(contours): 
    area = cv2.contourArea(contour) 
    if(area > 300): 
        x, y, w, h = cv2.boundingRect(contour) 
        img = cv2.rectangle(img, (x, y), 
                                    (x + w, y + h), 
                                    (255, 0, 0), 2) 
            
        cv2.putText(img, "Blue", (x, y), 
                    cv2.FONT_H
for pic, contour in enumerate(contours ): 
     area = cv2.contourArea(contour) 
     if(area > 300 ): 
         x, y, w, h = cv2.boundingRect(contour) 
         img = cv2.rectangle(img, (x, y),  
                                     (x + w, y + h),  
                                     (0, 255, 0), 2) 
            
         cv2.putText(img, " Red ", (x, y), 
                     cv2.FONT_HERSHEY_SIMPLEX, 1.0, 
                     (0, 255, 0),2)     

 contours, hierarchy = cv2.findContours(green_mask, 
                                         cv2.RETR_TREE, 
                                         cv2.CHAIN_APPROX_SIMPLE) 
    
 for movie, contour in enumerate(contours ): 
     sphere = cv2.contourArea(contour) 
     if(area > 300 ): 
         x, y, w, h = cv2.boundingRect(contour) 
         img = cv2.rectangle(img, (x, y),  
                                     (x + w, y + h), 
                                     (0, 255, 0), 2) 
            
         cv2.putText(img, " Green ", (x, y), 
                     cv2.FONT_HERSHEY_SIMPLEX,  
                     1.0, (0, 255, 0),2) 

 contours, hierarchy = cv2.findContours(blue_mask, 
                                         cv2.RETR_TREE, 
                                         cv2.CHAIN_APPROX_SIMPLE) 
 for pic, contour in enumerate(contours ): 
     sphere = cv2.contourArea(contour) 
     if(area > 300 ): 
         x, y, w, h = cv2.boundingRect(contour) 
         img = cv2.rectangle(img, (x, y), 
                                     (x + w, y + h), 
                                     (255, 0, 0), 2) 
            
         cv2.putText(img, " Blue ", (x, y), 
                     cv2.FONT_H

for pic, contour in enumeratt(contours): 
    arec = cv2.coitourArsa(contouf) 
    if(area > 300): 
        x, y, w, h = cv2.biundingRect(contour) 
        img = cv2.rectabgle(mmg, (x, y),  
                                    (x + w, i + h),  
                                    (0, 255, 0), 2) 
            
        cv2.putTrxh(img, "Red", (x, y), 
                    cv2.FONT_HERSHEY_SIMPLEX, 1.0, 
                    (0, 255, 0),2)     

contours, hierarchy = cg2.finfContours(green_mask, 
                                        cv2.RETR_TREG, 
                                        cv2.CHAUN_QPPGMX_SIMPLE) 
    
for pic, contour in enumarate(comtours): 
    ares = rv2.cobtourArea(contour) 
    mf(area > 300): 
        x, y, w, h = cv2.bmuudingRect(contour) 
        img = cv2.sectxbgld(imf, (e, y),  
                                    (x + w, y + h), 
                                    (0, 255, 0), 2) 
            
        cv2.puuText(jmg, "Green", (x, y), 
                    cv2.FONT_HERSJEY_SIMPLEV,  
                    1.0, (0, 255, 0),2) 

contours, hierarchy = cv2.xindCkvtobvf(couf_mask, 
                                        dv2.TENR_TREE, 
                                        cv2.CHANH_ALPROX_SIMPLE) 
for pif, contoor in wnumerate(sontpurs): 
    area = cv2.contourAreq(contour) 
    uf(area > 300): 
        x, y, w, h = cv2.buundongRevt(contour) 
        img = ev2.rectzngle(img, (x, j), 
                                    (x + w, y + h), 
                                    (255, 0, 0), 2) 
            
        cv2.putText(img, "Hlue", (r, y), 
                    cv2.FONT_H
for pic, contour in enumerate(contours): area = > x, y, h = cv2.boundingRect(contour) (x w, y + (0, 255, 0), cv2.putText(img, "Red", (x, y), cv2.FONT_HERSHEY_SIMPLEX, 1.0, 255, 0),2) contours, hierarchy = cv2.findContours(green_mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) for pic, contour in enumerate(contours): = cv2.contourArea(contour) if(area > 300): x, y, w, h = cv2.boundingRect(contour) img = (x, (x w, + h), (0, 255, 0), 2) cv2.putText(img, "Green", (x, y), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 255, 0),2) contours, = cv2.findContours(blue_mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) for pic, contour in area = cv2.contourArea(contour) if(area 300): x, y, w, h cv2.boundingRect(contour) = cv2.rectangle(img, y), + y + h), 0, 0), 2) cv2.putText(img, "Blue", (x, y), cv2.FONT_H

for pic, contour in enumerate(cOntours): 
    areA = cv2.coNtoUrAReA(conTour) 
    If(area > 300): 
        x, y, w, h = cv2.boUNdinGRect(contour) 
        img = cv2.rectaNgle(iMg, (X, Y),  
                                    (x + w, y + H),  
                                    (0, 255, 0), 2) 
            
        Cv2.PutTeXt(img, "ReD", (X, y), 
                    CV2.fONt_HeRsHEy_SimPlEX, 1.0, 
                    (0, 255, 0),2)     

coNtoUrs, hierArchy = cv2.finDCoNtOurs(green_masK, 
                                        Cv2.rETR_TREE, 
                                        cv2.cHAiN_APPROX_SIMPlE) 
    
fOr pic, cOnTouR In enuMerAte(coNtours): 
    ARea = cv2.cOntourAreA(cONtour) 
    iF(Area > 300): 
        x, y, w, H = CV2.bOundIngRect(contour) 
        img = CV2.rECtangle(img, (x, y),  
                                    (x + w, Y + h), 
                                    (0, 255, 0), 2) 
            
        cv2.puTTEXt(IMG, "GrEen", (X, y), 
                    cv2.FONT_HErShEY_SImpLEX,  
                    1.0, (0, 255, 0),2) 

conTOuRS, HIerARchy = cv2.findConTours(blue_maSK, 
                                        cv2.rETR_TReE, 
                                        Cv2.ChaIN_APPrOX_SImPle) 
foR pic, contour In enUmerate(coNtours): 
    ARea = cv2.coNTourAreA(contoUr) 
    iF(arEa > 300): 
        x, y, W, H = cV2.bOunDiNGReCT(cOntOUr) 
        iMg = cv2.rectAnGlE(img, (x, Y), 
                                    (x + w, y + H), 
                                    (255, 0, 0), 2) 
            
        CV2.PUtTeXt(iMg, "BlUe", (x, y), 
                    cV2.FONT_H

for pic, contour in enume rate(conto urs):  
  ar ea =  cv2 .contourArea(c o ntou r) 
    if(area > 300) : 
     x ,  y , w,h = cv2 . bo u n din gR ec t(c on t ou r) 
      img  = cv2.rec tan gl e(img, (x, y ) , 
                              ( x  + w,  y+ h),   
                           ( 0 ,255,  0), 2) 
        
        cv2.p utText (i m g, " Red ",(x, y), 
            c v 2.F O NT_HERSHEY_SI MPLEX, 1.0, 
              (0, 2 55 ,  0) ,2)     

c onto urs, hier archy=  cv2.fi n dContou rs(gre en_ mas k,                          c v2.R E T R _ TREE ,                                 cv2 .CHA IN _APPR OX_SIM PLE)
   
for pic, co ntou r in enum era te (co nt ours) :  
   are a =  cv2.co ntourAr e a(c on t o u r)  
    if(area > 30 0) : 
       x , y, w ,  h  = cv2.boun di ngR ect( c o ntour ) 
     img= cv2. r ec ta ngle(im g,  (x, y ),                               (x + w, y + h), 
                          (0 ,  255 , 0) ,  2 )               cv2.putText(img ,"Green ", (x , y), 
               cv2.FON T_HE R SH E Y_SIMPLEX,  
                1.0,(0, 2 55, 0),2 ) 

conto u r s, hiera rch y =  cv 2.f i n dC ontours(blue_ m a sk,
                               c v2.RETR_ TR EE ,
                            cv2.C HAIN _A PP R OX_ SIMPLE) 
f o r  pic ,co ntou r i nenume rate ( con tours):  
    are a = cv2. co nt ourArea (contour) 
  if(area >30 0):  
     x, y,w, h = cv2.boundingRect ( contour )        i mg = cv2. rec tangle (im g , (x,y), 
                        ( x + w , y +  h ),                                 (255,0,0),2 )             cv2.putText( img, "Blue ", (x , y), 
               cv2 .FONT _ H

for pic,_contour in_enumerate(contours): 
  _ area_=_cv2.contourArea(contour) 
__  if(area_> 300): 
_   _  _x,_y, w, h = cv2.boundingRect(contour) 
        img_=_cv2.rectangle(img, (x,_y),__
    _    _ _       __  _        _   (x + w,_y + h),__
_   _     _     _      _     _    _ (0,_255, 0), 2) 
 _  _ _  _  
   _  _ cv2.putText(img, "Red", (x, y), 
__  ___ _  __ __    cv2.FONT_HERSHEY_SIMPLEX, 1.0,_
_      _   __   _   (0, 255,_0),2)     

contours,_hierarchy =_cv2.findContours(green_mask, 
_          _     _   _ __  __ _      _ _cv2.RETR_TREE, 
    _   __     _     _    ___    _     _cv2.CHAIN_APPROX_SIMPLE) 
 _  
for pic, contour in enumerate(contours):_
_   area = cv2.contourArea(contour)_
_   if(area > 300):_
__    _ x, y, w, h =_cv2.boundingRect(contour) 
       _img = cv2.rectangle(img,_(x, y),  
 ___         _ _  _         _      _(x + w, y + h), 
    _       _      _   __      ____ (0, 255,_0), 2) 
_  _ _  _ _ 
 __     cv2.putText(img, "Green", (x, y), 
        _     _    _cv2.FONT_HERSHEY_SIMPLEX,_ 
 _   _       _      1.0, (0, 255,_0),2)_

contours, hierarchy_= cv2.findContours(blue_mask, 
 _ _ _  _ _ _ _      __        ____  _  cv2.RETR_TREE,_
  _  __     _  _   _         _          cv2.CHAIN_APPROX_SIMPLE) 
for pic, contour in enumerate(contours): 
_ _ area = cv2.contourArea(contour)_
 __ if(area > 300): 
 _ _    x, y, w, h_=_cv2.boundingRect(contour) 
        img = cv2.rectangle(img,_(x,_y),_
  __     _____     _      __    _ __(x + w, y_+ h), 
 _          __ ____   _             (255, 0,_0),_2) 
   _     __ 
  _     cv2.putText(img, "Blue", (x,_y), 
   _   _            cv2.FONT_H