BGR2HSV NOT WORKING [closed]

asked 2023-02-14 12:24:18 -0500

AGC gravatar image

I have been working on a code where the camera has to detect the color blue, and it works but instead of the image coming out well, what is orange comes out blue and what is blue comes out orange. this is my code:

 video=cv2.VideoCapture(1)
        ret, frame = video.read()
        if ret == True:
            frameHSV = cv2.cvtColor(frame,cv2.COLOR_BGR2HSV)
            mask = cv2.inRange(frameHSV,azulBajo,azulAlto)
            contornos, hierarchy = cv2.findContours(mask, cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
            for c in contornos:
                area = cv2.contourArea(c)
                if area > 3000:
                    M = cv2.moments(c)
                    if (M["m00"]==0): M["m00"]=1
                    x = int(M["m10"]/M["m00"])
                    y = int(M['m01']/M['m00'])
                    cv2.circle(frame, (x,y), 7, (0,255,0), -1)
                    font = cv2.FONT_HERSHEY_SIMPLEX
                    cv2.putText(frame, '{},{}'.format(x,y),(x+10,y), font, 0.75,(0,255,0),1,cv2.LINE_AA)
                    nuevoContorno = cv2.convexHull(c)
                    cv2.drawContours(frame, [nuevoContorno], 0, (255,0,0), 3)
edit retag flag offensive reopen merge delete

Closed for the following reason OpenCV Question: THe OpenCV community prefers to answer questions at: http://answers.opencv.org/questions/ by gvdhoorn
close date 2023-02-15 01:40:05.076783

Comments

I'm sorry, but this reads like a purely OpenCV question.

While we definitely use OpenCV with ROS, ROS Answers is not the place to ask questions about OpenCV.

Please repost your question at a more suitable venue, such as forum.opencv.org or robotics stack exchange.

gvdhoorn gravatar image gvdhoorn  ( 2023-02-15 01:41:38 -0500 )edit