Hi everyone! For a project I’m working on, I need to get a certain colored pixel from the camera. But I’ve ran into a problem; the camera works fine for a normal image you would get from the image library, but when you try letting the image take it from the camera, it tells you the method ‘get’ is not valid, or the image is not valid. Any ideas?
@Prynok Do you have a still image from the camera. I was able to do a get from an image from the camera without a problem. Just sample code below
function setup()
cameraSource(CAMERA_BACK)
end
function draw() -- This sets a dark background color
background(40, 40, 50)
img=image(CAMERA)
if xx~=nil then
sprite(xx,WIDTH/2,HEIGHT/2)
elseif img~=nil then
sprite(img,WIDTH/2,HEIGHT/2)
end
end
function touched(t)
if t.state==BEGAN then
xx=img
r,g,b=xx:get(200,200)
print(r,g,b)
end
end
While @SkyTheCoder’s method works, it’s slower since you need to rasterize the image every time you want to get a pixel. He probably knows that, though. That was just for demonstration purposes.