Log in or register to post comments

Possible to overlay text on the marker?

October 25, 2011 - 3:29am #1

Hi, rather than overlaying a 3D object over a marker, I would like to display a text string. Is this possible using the Qualcomm AR SDK?

Thank you!

Re: Possible to overlay text on the marker?

October 28, 2011 - 4:25am #18
kurisukun wrote:

Sorry, I'm a real openGL beginner. If it's rather trivial to put a flat surface and then apply a texture to the image, I'd appreciate any advice on this!

I think it's time you looked at those resources I pointed out - you've done pretty well so far, but there's only so much anybody can do via a forum. :-)

Re: Possible to overlay text on the marker?

October 28, 2011 - 4:21am #17

Actually, I sort of have it going (really, barely)! I used an OpenCV function call to get the correct perspective transform. Then I used the CATransform3D coreanimation to apply the transform to the UIView. It isn't quite perfect though.

With regards to the OpenGL route, actually I was also trying that in parallel. However, I really don't know how I'd go about it.

At this point, I'm trying to replace the teapot model with just a flat surface with vertices like this:

static const float squareVertices[] =
{
1, -1, 0,
1, 1, 0,
-1, 1, 0,
-1, -1, 0
};

But no luck yet. Sorry, I'm a real openGL beginner.

If it's rather trivial to put a flat surface and then apply a texture to the image, I'd appreciate any advice on this!

Re: Possible to overlay text on the marker?

October 28, 2011 - 4:14am #16

Hi kurisukun,

Yes it is possible - I did some preliminary research to use the trackable's pose matrix as a CGAffineTransform on a view.

The trick is getting the transformation into the same 'space' as OpenGL - but since you're after an 'impression' and not a exact alignment that should be easier.

There must be iOS developers out there who've done this sort of thing already.

Of course the other way is to draw your view into an image, and use the image as a texture within OpenGL...

Re: Possible to overlay text on the marker?

October 27, 2011 - 9:01am #15

Hello! I got this all working the other day. However, I'd like to give the app a little more "immersive" feeling than what it has now.

At this point, I have the app recognizing the marker and overlaying a UIView on top of it.

However, depending on the angle of the iPad to the marker, I was thinking to change the perspective of the UIView via CoreAnimation3D transforms. However, I'm not quite sure how this is done. Is this possible?

Thank you!

Re: Possible to overlay text on the marker?

October 26, 2011 - 1:09am #14

I just figured this out. It seems that I needed to update the UIKit elements via the main thread.

Re: Possible to overlay text on the marker?

October 26, 2011 - 1:04am #13

Hi again, sorry, I spoke too soon.

What I had done last night was to simply put some UILabel code within the viewDidAppear: method of OverlayViewController, which basically put a text string on the screen at app launch.

However, what I really wanted (as you know), is to put a UILabel when I detect a marker.

So, within EAGLview.mm within renderFrameQCAR loop, I had placed a NSNotification to send a notification to OverlayViewController. Within OverLayViewController, I then set up a NSNotification observer to pick up the notification, then call a selector showText() defined within OverlayViewController. Within showText, I've put the UILabel code to display a label, but nothing appears on the screen.

Simply put, when I generate a UILabel from within OverlayViewController's viewDidAppear() method, it shows up on my ipad. However, when I try to generate a UILabel from another function (showText) defined in OverlayView controller, nothing shows up.

I can't figure out why this is...how have you been implementing your UIKit elements on the screen? Did you take a similar approach?

Re: Possible to overlay text on the marker?

October 26, 2011 - 12:51am #12

I've not seen problems using UIKit over OpenGL - I think it's only a performance issue, and as you're only getting OpenGL to draw a single quad wiith texture (the camera view) - you're not going to hit any problems there.

It is possible that any UIKit view overlaying the OpenGL will be redrawn every frame, so bear that in mind, but to keep the implementation simple I'd keep to UIKit until performance requires you to render text in OpenGL.

On your forum question - try doing a Quote, logging in, canceling the Quote then doing a Reply. For some reason they sometimes jump to different log-ins.

Re: Possible to overlay text on the marker?

October 25, 2011 - 6:13pm #11

Hello! Thank you for the input -- it does seem that color doesnt matter, but as long as it's about 10"-40", it should be ok. I noted that the sample application, ImageTargets uses a target of 247mm (if I recall).

I was able to insert some code into the EAGLView:renderFrameQCAR loop (after commenting out the openGL code that drew the teapot) to draw a UILabel over the EAGLView.

However, I was also reading that it's not recommended to use UIKit objects over an EAGLView, and another technique might be to use something like the Texture2D class. I figured I might be able to use the CCTexture2D class from the cocos2d-iphone project to help with drawing text right within the EAGLView itself. If I understand correctly (but probably not), I should be able to plop a Texture2D-generated text string right there where the OpenGL code used to be in the renderFrameQCAR loop. Would this be correct?

Also, a side question about the forums. For some reason, I can only access this site from one mac. When I login to this site from my other macs at home and I try to reply/post/create thread I just keep getting redirected to the qdevnet login page. I try to login again and it seemingly logs me in (it shows "Hello kurisukun" at the top), but when trying to post, I get redirected to login again. Why might this be the case?

Thank you!

Re: Possible to overlay text on the marker?

October 25, 2011 - 8:25am #10

Size doesn't matter - apparent size does. Depending on the use of your app, you'll want the target to fill as much of the view as possible - that should help you with your decision about physical target size.

Take a moment to read the Dev Guide section of the web site - it will tell you about the different target/marker types.

Try out the sample apps with their targets to help inform your decisions.

Re: Possible to overlay text on the marker?

October 25, 2011 - 8:00am #9

Thank you for the descriptive answer! You've been a lot of help! I'm about to dive into the SDK now to get a feel for things.

I may have to come back here for more questions however -- I hope that is ok!

With regards to the markers themselves, are there any requirements? For example, in the samples, they are approximately A4 size. Is that the minimum required size for detection? Any other requirements for borders/colors/patterns/etc?

Thank you!

Re: Possible to overlay text on the marker?

October 25, 2011 - 7:29am #8
kurisukun wrote:

How trivial would it be to say, use QCAR to output a "hello world" onto a marker using the method you linked to? Could this be done relatively easily even using the provided SDK sample codes?

Sure - start with the required sample app (you may want to rename it) and in renderFrameQCAR inside the detected targets draw loop remove the OpenGL drawing code, and set some flags instead. Use these flags in another view to determine which text to display. Start with:

  • ImageTargets if you just want a couple of images to detect
  • FrameMarkers if you want to use predefined markers
  • MultiTargets if you want to use a cuboid shape to detect
  • VirtualButtons if you want to interact with the view.

A useful technique would be to use detection to reset a 'minimum duration of view' timer for the item. Show the text immediately if not already shown and hide it when the timer expires.

That could take anything between a few hours to develop, to a couple of days depending on your experience and the complexity of the pop-up content.

Re: Possible to overlay text on the marker?

October 25, 2011 - 6:12am #7

Thank you for the reply! I'll be sure to look for those texts you mentioned!

I should probably have stated my original question in not such a piecemeal manner.

As is the situation now, I need to create a very simple AR application (as a proof of demo for now) by this week. Simply put, I will use an ipad 2, a marker, and once the marker is recognized, some random text strings will show up. I'm hoping that this isnt really that difficult. :)

I've done iOS programming before, but never an AR application nor OpenGL. How trivial would it be to say, use QCAR to output a "hello world" onto a marker using the method you linked to? Could this be done relatively easily even using the provided SDK sample codes?

I have yet to dig deeper into the SDK to understand more about what kind of markers can be recognized, but if you have any tips, that would be great!

Thank you!

Re: Possible to overlay text on the marker?

October 25, 2011 - 4:20am #6
kurisukun wrote:

I'm actually new to OpenGL programming, so I can't quite say that I fully understand what's going on there! :)

My key references when starting on OpenGL were "iPhone 3D Programming" by Philip Rideout and the blog by Jeff Lamarche.

kurisukun wrote:

I noticed in another thread that iOS 5 and QCAR has some flickering issues. Might this still be the case even when using UILabels in the AR view?

We haven't been able to reproduce this ourselves so I shouldn't worry unless you see it - we are working with the developer to isolate the problem.

Re: Possible to overlay text on the marker?

October 25, 2011 - 4:12am #5

Thank you!

I'm actually new to OpenGL programming, so I can't quite say that I fully understand what's going on there! :)

I noticed in another thread that iOS 5 and QCAR has some flickering issues. Might this still be the case even when using UILabels in the AR view?

Thank you!

Re: Possible to overlay text on the marker?

October 25, 2011 - 4:00am #4
kurisukun wrote:

However, you link you provided is to a Youtube video. Perhaps did you mean to post another link?

Oops - a C+P error - now fixed - please retry.

Hope you enjoyed the video! ;-)

Re: Possible to overlay text on the marker?

October 25, 2011 - 3:56am #3

Hi, thanks for the reply!

However, you link you provided is to a Youtube video. Perhaps did you mean to post another link?

Thank you!

Re: Possible to overlay text on the marker?

October 25, 2011 - 3:43am #2

Hi kurisukun,

Take a look at this post - it shows how to determine a coordinate in the UIView so you can position a UILabel or UITextControl.

http://ar.qualcomm.at/node/2000738

Alternatively you may just want to pop up a fixed size and position text view when the target is detected. For both solutions you need to invoke your view display code when a target is first detected, and have some means of dismissing it - either from the user or when the target is no longer tracked.

See the loop that iterates over detected and tracked items in EAGLView:renderFrameQCAR.

Log in or register to post comments