Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Capture a photo on camera
Started by blablu1212 Oct 08 2015 09:20 AM

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

blablu1212

[GLOBAL: userInfoPane.html]
blablu1212
  • Contributor

  • 122 posts
  • Corona SDK

Hello, 

I need to take a photo and focus between the shape boundaries. (similar to the image attached).

I would like to know if is it possible in corona to crop that specific shape and filter a person face shape? 

 

Attached Files



[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @blablu1212,

This is currently possible on iOS, but not on Android. Or rather, you could accomplish it in Corona Enterprise for both platforms, but only on iOS using the base Corona SDK.

 

Best regards,

Brent



[TOPIC: post.html]
#3

blablu1212

[GLOBAL: userInfoPane.html]
blablu1212
  • Contributor

  • 122 posts
  • Corona SDK

I am able to capture a photo by using:   media.capturePhoto()

I am trying to create the face shape as an image object to set over when camera is on and crop it after, but it's not working the right way.
Please may you guide which method should i use?

Regards



[TOPIC: post.html]
#4

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @blablu1212,

Take a look at the last example on this page...

 

https://docs.coronalabs.com/api/type/ShapeObject/fill.html



[TOPIC: post.html]
#5

blablu1212

[GLOBAL: userInfoPane.html]
blablu1212
  • Contributor

  • 122 posts
  • Corona SDK

Hi @Brent,

Thank you for your guide. 
I tried the code and it looks like it works only for geometric shapes like rectangle or circle.

Because when i try to add an image of transparent background but with a face shape it looks all a white rectangle.



[TOPIC: post.html]
#6

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @blablu1212,

From your original sample screenshot, I thought the idea was to have the photo (camera) on the large background rectangle, and then you place the white head/face outline with transparent background over the rectangle...

 

Brent



[TOPIC: post.html]
#7

blablu1212

[GLOBAL: userInfoPane.html]
blablu1212
  • Contributor

  • 122 posts
  • Corona SDK

Hi @Brent,

Yes that's the idea, i can place the camera on the rectangle background using shapeobject you guide me, but i can't place the white head/face outline over it while camera is capturing the image. Because the idea is the white head outline will behave as a border to focus the human face, take the picture and crop it after.
Is this possible to achieve? 



[TOPIC: post.html]
#8

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @blablu1212,

If you're doing the "camera fill" on the rectangle, then it's just another Corona display object. So, you can place the white outline on top using standard display group/object z-index ordering.

 

Brent



[TOPIC: post.html]
#9

blablu1212

[GLOBAL: userInfoPane.html]
blablu1212
  • Contributor

  • 122 posts
  • Corona SDK

Thank you @Brent, it works that way an object over another, so i can use it right as an outline guide.

Excuse me if i insist one more time on getting it all clear: What about cropping the photo as an irregular shape (face shape) ?
Please can you assist me on knowing the right method?



[TOPIC: post.html]
#10

blablu1212

[GLOBAL: userInfoPane.html]
blablu1212
  • Contributor

  • 122 posts
  • Corona SDK

Hi @Brent,

I created a group object to appear over on the screen when camera is on and seems like on a real device it doesn't work.
Should i simplify this problem and open it as another question?

 

Thanks



[TOPIC: post.html]
#11

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @blablu1212,

What device are you testing on?

 

Brent



[TOPIC: post.html]
#12

blablu1212

[GLOBAL: userInfoPane.html]
blablu1212
  • Contributor

  • 122 posts
  • Corona SDK

@Brent I am testing on android device, samsung galaxy sII.

 

Here is the code i am using to display an object on the screen while camera is on.

But seems that the object i put over (in this case an image with transparent background) doesn't appear when i test it on real device. 

If i create the object inside the "if media.hasSource" statement it won't appear neither.

Please may you help.

 

-- camera
local function onComplete( event )
local photo = event.target
print( "photo w,h = " .. photo.width .. "," .. photo.height )
end

if media.hasSource( media.Camera ) then
media.capturePhoto( { listener=onComplete } )
else
native.showAlert( "Corona", "This device does not have a camera.", { "OK" } )
end

-- image group
local group = display.newGroup()
group.x=150
group.y=100

local myImage = display.newImage( "myimage.png" )
myImage.width=300
myImage.height=300
group:insert( myImage )


[TOPIC: post.html]
#13

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @blablu1212,

As I mentioned in the second post of this thread, the "camera fill" feature is only available for iOS. It is not supported on Android at this time.

 

Brent



[TOPIC: post.html]
#14

Alex@Panc

[GLOBAL: userInfoPane.html]
Alex@Panc
  • Corona Geek

  • 1,733 posts
  • Corona SDK

What's happening, is that the device's native camera is being opened at the point when you call media.capturePhoto(). This is leaving the Corona app's environment and going to the device's phone thread. From the docs:

 

 

 

Overview

Opens a platform-specific interface to the device's camera. This function is asynchronous, meaning that it returns immediately so the calling code will continue to execute until the end of its scope; after that, the application will be suspended until the session is complete. 

 

You won't be able to overlay a Corona display object over the camera view in this fashion. What you (I believe) want to do, is use the object.fill() API (as Brent referenced above) to have a "live feed" display object, and then overlay a Corona display object on that. See the below thread for more info on this:

 

https://forums.coronalabs.com/topic/58834-shapefill-typecamera



[TOPIC: post.html]
#15

blablu1212

[GLOBAL: userInfoPane.html]
blablu1212
  • Contributor

  • 122 posts
  • Corona SDK

Hi @Alex@Panc,

Thank you for your detailed answer.
Yes that would make the trick, but object.fill it's not able for android devices :(
I need an alternative way to reach it, but seems like it's not possible in corona.

 

Regards




[topic_controls]
[/topic_controls]