Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Getting pixels from camea.

edited February 2014 in General Posts: 577

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?

Thanks, Prynok


  • dave1707dave1707 Mod
    edited February 2014 Posts: 8,968

    @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
  • Posts: 577

    @dave1707 Thanks, I got it working, your way is probably easier though!

  • Posts: 1,976

    CAMERA is simply the string "CAMERA." You needed to use image(CAMERA):get(...)

  • Posts: 2,820

    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.

Sign In or Register to comment.