How to detect object of particular color in OpenCV?

We can extract any color of image using color space and inRange function. Convert image BGR to HSV. then threshold the HSV image for a range of red color.