Modify ROI in the mask [closed]

asked 2014-08-04 15:47:16 -0600

updated 2014-08-05 02:57:06 -0600

Hi! Hello, I am a engineer student in Universidad Católica de Temuco and currently I'm working on my thesis. I'm making a prototype in real time chroma key on linux (ubuntu 11|.04). So this prototype is being developed in python with opencv and simplecv library and I wonder if there is any chance to help me with the mask in simplecv and opencv. Any kind of help,examples or doumentation would be useful for my research. source code

from SimpleCV import *
import cv2
import numpy as np
from PIL import Image
from SimpleCV import *
from ImageChops import subtract
import math
greenscreen = Image("ploc.png")
#Iniciamos la camara
captura = cv2.VideoCapture(0)
imagen1= cv2.imread('JUE14.PNG')
#captura.set(3,1024)
#captura.set(4,780)
captura.set(3,400)
captura.set(4,266)

while(1):

    #Capturamos una imagen y la convertimos de RGB -> HSV
    _, imagen = captura.read()

    hsv = cv2.cvtColor(imagen, cv2.COLOR_BGR2HSV)

    #Establecemos el rango de colores que vamos a detectar
    #En este caso de verde oscuro a verde-azulado claro
    verde_bajos = np.array([49,50,50], dtype=np.uint8)
    verde_altos = np.array([80, 255, 211], dtype=np.uint8)
    rojo= np.array([0,255,0], dtype=np.uint8)
    #Crear una mascara con solo los pixeles dentro del rango de verdes
    mask = cv2.inRange(hsv, verde_bajos, verde_altos)

    #prueba de mascara resultante  quitando bit a bit los pixeles
    res = cv2.bitwise_and(imagen,imagen,mask=~mask)



    cv2.imshow('mask', mask)
    cv2.imshow('Camara', imagen)
    cv2.imshow('res', res)

    #cv2.imshow('res2', mask2)
    #cv2.imshow('ploc', ploc)
    tecla = cv2.waitKey(5) & 0xFF
    if tecla == 27:
        break

cv2.destroyAllWindows()

I need replace ROI (in res window) for any background (picture or video)

Regards.

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by StevenPuttemans
close date 2014-08-05 02:59:04.613486

Comments

I am sorry but since you are explicitly using simpleCV which is not an official OpenCV package, I have to refer you to the correct Q&A forum and lock down this topic. We do not handle external packages and wrappers here.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-05 02:58:39 -0600 )edit