1.opencv函数cvCvtColor(rgb_im,hsv_im,CV_BGR2HSV)中使用的RGB颜色空间转到HSV算法: max=max(R,G,B) min=min(R,G,B) if R = max, H = (G-B)/(max-min) if G = max, H = 2 + (B-R)/(max-min) if B = max, H = 4 + (R-G)/(max-min) H = H * 60 if H < 0, H = H + 360 V=max(R,G,B) S=(
import cv2 import numpy as np cap = cv2.VideoCapture(0) # set blue thresh 设置HSV中蓝色.天蓝色范围 lower_blue = np.array([78,43,46]) upper_blue = np.array([110,255,255]) while(1): # get a frame and show 获取视频帧并转成HSV格式, 利用cvtColor()将BGR格式转成HSV格式,参数为cv2.COLOR_BGR
Mat src=imread("image/color.jpg"); imshow("a",src); int i,j; int cPointR,cPointG,cPointB,cPoint;//currentPoint; for(i=1;i<src.rows;i++) for(j=1;j<src.cols;j++) { cPointB=src.at<Vec3b>(i,j)[0]; cPointG=src.at<Vec3b>(i,