I am trying to take a picture with the Poppy Ergo Jr camera, and process the image. I am trying to convert the image into HSV, then find all the pixels in the image that fall within that range. My code works as intended in my own Jupyter Notebook with images I have taken off of the Poppy camera.
However, when I try to run my exact code inside the Poppy Notebook, I am not getting what I expect. It seems like it has something to do with the way the Poppy camera is saving the images.
If anyone can assist it would be very much appreciated!
Here is my code:
from future import print_function
from pypot.creatures import PoppyErgoJr
poppy = PoppyErgoJr()
bgr = poppy.camera.frame cv2.imwrite('bgr.jpg', bgr) img = cv2.imread('bgr.jpg') hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) lowerHSV = np.array([33, 120, 60]) upperHSV = np.array([102, 255, 255]) kernelOpen=np.ones((5,30)) mask = cv2.inRange(hsv, col_MIN, col_MAX) maskNoiseAdjust = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernelOpen) totalFound = cv2.countNonZero(mask) im = hsv[:,:,0] percentage = totalFound/im.size return percentage
Based on my testing in my own Jupyter notebook, I should get a non-zero value returned, but within the Poppy notebook I am only getting zero.