Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Camera Feeds as Textures
Started by Bryan01 Dec 19 2013 01:08 PM

48 replies to this topic
[TOPIC CONTROLS]
Page 2 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

RedBeach

[GLOBAL: userInfoPane.html]
RedBeach
  • Corona Geek

  • 1,132 posts
  • Corona SDK

I just made a simple code here and also saw the problem of the camera not refreshing.

 

But then I downloaded the Corona Camera Fill Sample code and it worked fine.

 

Just sad that it sill doesn't support Front Camera and Android.



[TOPIC: post.html]
#27

paolo.longato

[GLOBAL: userInfoPane.html]
paolo.longato
  • Contributor

  • 114 posts
  • Corona SDK

Any news on front Camera usage (iOS or Android)?  It would open some interesting possibilities: having seen Walter's face on the demo video I would have assumed front camera was going to be working...



[TOPIC: post.html]
#28

sirmania

[GLOBAL: userInfoPane.html]
sirmania
  • Contributor

  • 150 posts
  • Corona SDK

Hoping for the front camera support  :rolleyes:



[TOPIC: post.html]
#29

sirmania

[GLOBAL: userInfoPane.html]
sirmania
  • Contributor

  • 150 posts
  • Corona SDK

By the way I used this to update the camera fill and it works fine:

 

 local crate = display.newRect(centerX, centerY, 320, 480 )
 crate.fill = { type="camera" }
  
    local function updateCamera()
        crate.fill = { type="camera" }
    end
 
 Runtime:addEventListener("enterFrame", updateCamera)


[TOPIC: post.html]
#30

eltromac

[GLOBAL: userInfoPane.html]
eltromac
  • Observer

  • 13 posts
  • Corona SDK

Does anybody have crash after removing display object with camera feed?

I don't how to remove camera feed.



[TOPIC: post.html]
#31

BeyondtheTech

[GLOBAL: userInfoPane.html]
BeyondtheTech
  • Contributor

  • 477 posts
  • Corona SDK

For gits and shiggles, I added this to my game and it's rather cool, but I'd really like to get front-camera support as well.  I'll see if there's a crash when trying to remove it, but I figure maybe just change the fill before deleting the display object?



[TOPIC: post.html]
#32

WarrenW

[GLOBAL: userInfoPane.html]
WarrenW
  • Contributor

  • 830 posts
  • Corona SDK

What do you do to keep the live feed updated? I heard someone say they add a pixel and move it some. Can you show me what you do?

 

Thanks!



[TOPIC: post.html]
#33

BeyondtheTech

[GLOBAL: userInfoPane.html]
BeyondtheTech
  • Contributor

  • 477 posts
  • Corona SDK

It just so happens that my background image was constantly moving with the accelerometer, and i had a game loop that performed this every 100ms, so I never had a problem with getting a live feed.

transition.cancel( skyGroup.trans )
skyGroup.trans = transition.to( skyGroup, { time = 100, x = 50 * ( 0.5 - accel.xGravity ), y = 50 * ( 0.5 - accel.yGravity ) } )


[TOPIC: post.html]
#34

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

Regarding the landscape issue, can someone provide a better description of what happens when you rotate the camera to landscape mode?  Perhaps a diagram of what should happen?

 

Thanks

Rob



[TOPIC: post.html]
#35

RedBeach

[GLOBAL: userInfoPane.html]
RedBeach
  • Corona Geek

  • 1,132 posts
  • Corona SDK

It is very strange, it appears the axis don't get rotated on the landscape... like,  if you move the camera to the LEFT, what you see inside the feed goes DOWN (or UP, I don't remember) and vice-versa. And the image from the feed appears to be distorted.

 

 

There is a work-around for that problem (someone posted it in the forum and I am using it and it works fine). The work-around is basically to invert width with height and rotates -90.

 

 

The code that I use on my bar code reader is:

    local cameraShapeW = params.width
    local cameraShapeH = params.height
    local cameraShape
    local shapeRotation = 0
    
    local isLandscape = display.contentWidth > display.contentHeight    
    if isLandscape and params.fill.type == "camera" then
        local t = cameraShapeW
        cameraShapeW = cameraShapeH
        cameraShapeH = t    
        shapeRotation = -90
    end    
    cameraShape = display.newRect(params.x, params.y, cameraShapeW, cameraShapeH )
    cameraShape.anchorX = 0.5
    cameraShape.fill = params.fill
    cameraShape.rotation = shapeRotation
 

 



[TOPIC: post.html]
#36

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

I need a good description to give engineering or a filed bug report with a sample project so they can see what's going on.

 

Rob



[TOPIC: post.html]
#37

RedBeach

[GLOBAL: userInfoPane.html]
RedBeach
  • Corona Geek

  • 1,132 posts
  • Corona SDK

Just tell them to create a landscape app with a rectangle that uses a camera fill.



[TOPIC: post.html]
#38

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

I'd really like to get Engineering to fix this, but we need a test case.

 

Rob



[TOPIC: post.html]
#39

scottadelman

[GLOBAL: userInfoPane.html]
scottadelman
  • Contributor

  • 237 posts
  • Corona SDK

Is landscape camera feed supported yet?



[TOPIC: post.html]
#40

WarrenW

[GLOBAL: userInfoPane.html]
WarrenW
  • Contributor

  • 830 posts
  • Corona SDK

Can you just rotate the object by 90 degrees in your app? Or do that for everything else on the screen. I did that before when I wrote a game in landscape but the rest of the app was portrait.

 

Warren



[TOPIC: post.html]
#41

scottadelman

[GLOBAL: userInfoPane.html]
scottadelman
  • Contributor

  • 237 posts
  • Corona SDK

We definitely could do that, but if landscape is supported, Id rather not...



[TOPIC: post.html]
#42

scottadelman

[GLOBAL: userInfoPane.html]
scottadelman
  • Contributor

  • 237 posts
  • Corona SDK

Ok did a test run in portrait.. I should be able to make this work, but it is going to be a big pain to work with a sideways simulator....

 

So even in portrait mode I am getting distortion... the y axis appears stretched... what can I do about this?



[TOPIC: post.html]
#43

RedBeach

[GLOBAL: userInfoPane.html]
RedBeach
  • Corona Geek

  • 1,132 posts
  • Corona SDK

Your shape (that you fill using Camera Feed) needs to be in the same aspect ratio of the camera, otherwise it will be stretched. The iOS cameras use a 4:3 ratio.

 

 

About the landscape, the code that I posted before works fine for landscape mode.



[TOPIC: post.html]
#44

scottadelman

[GLOBAL: userInfoPane.html]
scottadelman
  • Contributor

  • 237 posts
  • Corona SDK

Awesome!!  Thanks for the help Renato!  That fixed both issues!!



[TOPIC: post.html]
#45

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

I wonder when we will see Android support for this amazing feature. Fingers crossed. 



[TOPIC: post.html]
#46

scottadelman

[GLOBAL: userInfoPane.html]
scottadelman
  • Contributor

  • 237 posts
  • Corona SDK

Ok so, it fixed the issue of the distortion on the iPhones.  It did not correct it for iPad.  It appears that the ratio to avoid distortion on the iPad is nearly 2:1  So the box will need to be 2x as wide as it is tall.  In order to cover the whole screen, you have to go well outside the bounds of the screen.  The issue then is the camera feed becomes extremely zoomed in.  I tried to use .fill.scaleX to scale the camera feed, but no luck.  Anyone have any other ideas?

 

Thanks,
Scott



[TOPIC: post.html]
#47

ojnab

[GLOBAL: userInfoPane.html]
ojnab
  • Contributor

  • 535 posts
  • Corona SDK

@scott

Did you solve the iPad ratio/scale problem?



[TOPIC: post.html]
#48

scottadelman

[GLOBAL: userInfoPane.html]
scottadelman
  • Contributor

  • 237 posts
  • Corona SDK

@ojnab - So trying to recall off the top of my head, but the ipad ration ended up being 16:9.. so if your display.newRect is like 640x360 it will not case distortion.  It appears to be using the iPads video capture ration and not its picture. 

 

You can see the zoom difference when selecting video vs camera in the ipads camera app.  The feed matches the feed on the video.

 

I could find no way to "zoom" the feed in... which was problematic for what I was doing..  if anyone knows a way to zoom, it would be awesome as I am going back to that app soon.

 

Scott



[TOPIC: post.html]
#49

ojnab

[GLOBAL: userInfoPane.html]
ojnab
  • Contributor

  • 535 posts
  • Corona SDK

@scott

Thanks. 

To add to the confusion I just discovered that the back-facing camera on the iPad uses 16:9 ratio but the front-facing camera uses 4:3 ( same as iPhone ). So to avoid stretching - the ratio of the camera fill object needs to be changed when toggling between the cameras.




[topic_controls]
Page 2 of 2 1 2
 
[/topic_controls]