Posted on by

Earlier in the year, we showed off a feature that teased developers with the ability to create shapes attached to the device’s camera feed.

Today, we’re happy to announce that this feature has been added to daily build 2013.2106 for iOS devices. This functionality will allow developers to use the camera feed as a texture, which means the texture can be placed under objects and overlays, on top of objects, within containers, or attached to box2d objects.

In addition, developers can also apply effects to the real-time camera feed, which results in some neat distortion of the environment.

We can’t wait to see what the community does with this!

To set the shape’s texture fill to the camera feed, it is as simple as defining the shape and setting the fill type to camera:


local shape = display.newRect( 0, 0, 320, 480 )
shape.anchorX = 0
shape.anchorY = 0
shape.fill = { type="camera" }

Setting the effect on the camera feed works the same way as setting an effect on existing fill types. For example, the sobel, and pixelate filter works on the camera feed in real-time to produce the final visual effect with the syntax below:


--Example effects
shape.fill.effect = "filter.sobel"
shape.fill.effect = "filter.pixelate"

We’re adding two sample projects to our Github repository. One sample shows several fish overlayed on top of the video feed, with the ability to toggle filters. The second sample shows several box2d objects with the camera feed as the fill and different filter effects applied to each shape object.

The two sample projects are available here.

Since there are countless new ways to exercise this functionality, this feature should be treated as a beta feature. This feature works with most single-pass filters and is only available to Pro and above users.

See the video below for an example.

Happy Holidays!


Posted by . Thanks for reading...

34 Responses to “Holiday Surprise: Camera Feeds as Textures, Real-Time Effects”

  1. Juf Jannie

    Will you be able to add custom video files instead of the camera feed? Alos will you be able to record the “texture” to a video file?
    It seems it is possible now to add a video file inside your app instead of the separate layer on top of everything it is now.

    Reply
    • alexf

      Kerem, i’m pretty sure it’s Reflector, and capturing the Mac stream with your video capture software of choice.

      alex

      Reply
      • Kerem

        Thanks for your response. So I gather this API runs on the simulator as well using the built-in camera on the Mac. All the better.

        Reply
        • Walter

          Right now, it’s only on iOS devices. The camera/GL texture binding is extremely platform-specific.

          Reply
          • Kerem

            It is quite an achievement!!! So if the demo ran on an IOS device may I ask how the video of the demo was captured? I am interested in learning how to capture demos off the device but did not think it was possible to do this. Thanks for sharing.

          • Kerem

            Please ignore my question. Apparently AlexF had answered it all along. Just Googled Reflector IOS and I have my answer.

  2. Andrew Schisas

    Why always ios first when android is the future.. Never understand that but looking forward to have it available for android.

    Reply
  3. Simon Robertson

    What a sweet surprise! I’ve had way too much fun experimenting with this today. Thanks.

    Question: Is it possible to load the front (facetime) camera by default? This goes for regular old media.capturePhoto() as well.

    Reply
  4. Andrew Schisas

    Hehe. No we arent gonna do that.. just going off the forums and facts hehe.. but in same regards, it is uite annoying how u guys always tease the android developers with things u can’t do.. why not hold back and release together? Just a question.

    Reply
    • Juf Jannie

      Why should it be delayed for android? I sell Android and iPhone apps. This means I can already start making money and building the app at the iphone side. When android support comes I can just rebuild and upload to Android.
      And it isn’t Android vs Apple developers. if so you should have stayed at java stuff.
      My guess is people use corona cause they want both.
      It just means part of your sales model has to wait a bit.

      Reply
  5. Andrew Schisas

    Hehe in no way was i sparking an android vs ios debate.. thank u kerem for posting an article from “apple insider”.. I wonder if there was an “android insider” if would still favour ios.. that would be funny if it didn’t.. wow u make a comment and u guys quick to gang up haha.. but thank u Juf for your comment, you made a very good point.. wished Kerem could have been able to answer but sometimes it takes an outsider to shine some light.. The whole suggestive insult to go back to java was not necessary though as I did state that it was just a question but am glad that you think it was a “perfect” comment insult and all Kerem, real professional buddy.. Apologies if my writing style has suggested to you that I wanna partake in a childish debate as honestly have better things to do with my time such as making apps with the great and fantastic Corona SDK.. Keep up the great work guys and I look forward to continue to watch Corona grow :) Peace guys

    Reply
  6. Kerem

    Andrew, apologies if I caused any upset. Was not the intention at all. I would love to see more Android love as well. I have nothing against the platform and this thread is definitely not a good place to have a go at this anyways. Also note I do not work for or speak for Corona Labs. Not sure if there was a misunderstanding about this.

    Keep well and enjoy the holidays. All is good.

    Reply
  7. Vasant

    Thanks for the great addition and a nice surprise.

    Can you choose which camera get used by this feature? (when devices have 2 cameras it seems to default to the main backside camera) Can you change the default camera to be front camera?

    Reply
  8. Caleb

    I tried to run it in the simulator but it crashes immediately… any fix please? I’ve included the top portion of the error log.

    Process: Corona Simulator [12688]
    Path: /Applications/CoronaSDK/Corona Simulator.app/Contents/MacOS/Corona Simulator
    Identifier: com.coronalabs.Corona_Simulator
    Version: 2013.2100 (2013.2100)
    Code Type: X86-64 (Native)
    Parent Process: Sublime Text 2 [8793]
    User ID: 502

    Date/Time: 2013-12-28 10:19:48.953 +1300
    OS Version: Mac OS X 10.8.5 (12F45)
    Report Version: 10

    Interval Since Last Report: 38953 sec
    Crashes Since Last Report: 7
    Per-App Interval Since Last Report: 27138 sec
    Per-App Crashes Since Last Report: 7
    Anonymous UUID: 50F9A7F7-8914-E9FD-18BE-F46B067622D6

    Crashed Thread: 0 Dispatch queue: com.apple.main-thread

    Exception Type: EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes: KERN_INVALID_ADDRESS at 0×0000000000000000

    VM Regions Near 0:
    –>
    __TEXT 000000010f57a000-000000010f780000 [ 2072K] r-x/rwx SM=COW /Applications/CoronaSDK/Corona Simulator.app/Contents/MacOS/Corona Simulator

    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0 com.coronalabs.Corona_Simulator 0x000000010f5cc8a3 Rtt::GLCommandBuffer::Execute(bool) + 177
    1 com.coronalabs.Corona_Simulator 0x000000010f5d1737 Rtt::Renderer::Render() + 63
    2 com.coronalabs.Corona_Simulator 0x000000010f6391d1 0x10f57a000 + 782801
    3 com.coronalabs.Corona_Simulator 0x000000010f6148e7 0x10f57a000 + 633063

    Reply
    • David

      Caleb, looks like this is because you are using build 2100. This feature was introduced in 2106, so you need that build (or later) to have this work.

      Reply
  9. Fredrik

    okey, so lets say i wanted to make a camera app. would it be possible to make on with this new graphics engine? lets say i show this feed in a texture, and then i want to use a button to capture a photo. exactly how would you do that?

    Reply
    • David MEKERSA

      Fredrik, same need here I wanted to use this camera texture as a photo preview and allow the user to capture it. I think it’s not possible for now. So our app needs to open the camera native UI to capture the photo which break the user experience. Sad. I’m sad it’s iOS only too. This kind of feature looks more like alpha feature than real feature. Not mentioning that when I tested it, the texture was not refreshing. Definitely an alpha level…

      Reply
      • Raphael Salgado

        I just did a display.save() method while the my background display object was the camera feed and it captured it. I know it’s not going to be the full resolution of the camera, but it’s a start.

        Reply
  10. Josep Alemany Fruitos

    Any news about the Android version? we need it portable as soon as possible… Thanks!

    Reply
  11. Nikola Minoski

    I’m interested too about Android version of Camera Feeds as Texture. We need it asap, in order to decided to use Corona SDK or go native.. Thanks!

    Reply

Leave a Reply

  • (Will Not Be Published)