1

Here is my code:

import cv2
import numpy as np
cap = cv2.VideoCapture(1)
fourcc = cv2.VideoWriter_fourcc('M','J','P','G')
framesize = (640,480)
out = cv2.VideoWriter('dump.avi',fourcc,60.0,framesize)
font = cv2.FONT_HERSHEY_SIMPLEX

while True:
        ret, frame = cap.read()
        gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
        cv2.imshow('frame',frame)
        cv2.rectangle(gray, (0,0),(640,480),(255,255,255),3)
        cv2.putText(gray, "gray", (0,130),font, 5,(255,255,255),2,   cv2.LINE_AA)
        cv2.imshow('fr',gray)

Here I am trying to color a specific square area on the live image feed

        #gray[100:105,110:115] = [255,255,255]
        io = gray[37:111,107:194]

Here I am cloning an are into another

        gray[200:200,270:283] = io
        out.write(frame)        
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

cap.release()
out.release()
cv2.destroyAllWindows()

How can I color a specific area? As my attempt is not working.

Martin Evans
  • 45,791
  • 17
  • 81
  • 97
  • You can try **overlaying** the area of interest with a specific color. To know more about overlaying visit [THIS PAGE](http://stackoverflow.com/questions/41376337/applying-overlays-to-image-with-varying-transparency/41381887#41381887) Using this you can also make your area cor with transparency – Jeru Luke Jan 16 '17 at 11:37

0 Answers0