Sunday, 10 October 2010

Augmented reality on the iPhone with iOS4.0

This post has moved to here

17 comments:

  1. Great Demo for Augmented Reality.
    Thanks a lot.

    ReplyDelete
  2. Excellent!!!!!
    Thx a bunch!!!!!

    ReplyDelete
  3. Hi Chris, what about a marker recognition? Do you have some place to point for that? Have you some snippet code to show?
    Really Thanks!!

    ReplyDelete
  4. So glad to find this. And I echo Chris's question about marker recognition. Thanks for this.

    ReplyDelete
  5. I'm sorry, I meant Giasone's question about marker recognition.

    ReplyDelete
  6. @Giasone and Alyoshak - there's a pretty good toolkit available here that does what you want: http://www.hitl.washington.edu/artoolkit/. Unfortunately for commercial use you have to pay.

    What you could try doing is identifying the square in the image that contains the marker, pull it out and then pass it through one of the QR libraries - something like http://code.google.com/p/zxing/ would work.

    You might want to take a look at my post about Sudoku Grab - there's some information there about pulling out regions from images and perspective correcting them - http://sudokugrab.blogspot.com/2009/07/how-does-it-all-work.html

    ReplyDelete
  7. Chris, Thanks for the toolkit suggestion. By the way, I haven't been able to overcome build errors in ARDemo, all of them stemming from the inability to correctly find header files in AVFoundation framework. I know this is some kind of problem on my end, but did you have any problems with this? The AVFoundation framework is definitely added to the project. I simply downloaded the demo, expanded the compressed files, and opened it with Xcode. Any suggestions? 58 errors of stuff like "AVFoundation/AVCaptureSession.h: No such file or directory".

    ReplyDelete
  8. @Alyoshak Sounds like it's not finding the AVFoundation framework - are you building for 4.0? it wasn't introduced until then.

    ReplyDelete
  9. Also, make sure you are building for the device - it won't build for or work on the simulator.

    ReplyDelete
  10. I figured out a little earlier that I wasn't building for the device, but when I proceeded to build for it, I got even more errors (went from 19 to 58). I finally got rid of the problem, but I don't know why what I did worked. I just created a new, basic project from scratch, added the needed frameworks and added a line of code that tested whether it was finding everything it needed from the AVFoundation framework. It found it fine. So I proceeded to reconstruct the app either cutting and pasting code or importing the needed class files from the ARDemo project. She's working fine now. Sorry I couldn't figure it out. Oh, I'm building for 4.1 to answer your question.

    ReplyDelete
  11. Chris, I have another question if you have time. I've tried several times while inside captureOutput to make invocations of methods that modify ARView, but to no avail. For example, now I'm trying to change the color of a rectangle being drawn in ARView in response to having identified a certain pattern in the sampleBuffer. I try this by calling a BOOL setter on ARView and then sending it the setNeedsDisplay method so that it will redraw itself. Nothing happens because its drawRect method never gets invoked. But I learned that if I simply put the same two lines of code in the viewWasTapped method, ARView behaves as expected (updates its view with rectangle of changed color). Is there something about the captureOutput method that renders it incapable of communicating with objects of different classes? Can't find anything online about this.

    ReplyDelete
  12. @AlyoshaK - the captureOutput is running on a thread so cannot access UIKit objects. You need to use performSelectorOnMainThread.

    ReplyDelete
  13. Hi Chris nice work ! i was wondering how can i make a button that is like the shoot button of the iphone, a button somewhere that when you click it saves the image in a UIImage variable

    Thanks for the great code!

    ReplyDelete
  14. Thanks a lot, very helpful, any tip how to continue to recognize a marker forexample? how to analize the raw data?
    Thanks

    ReplyDelete
  15. Thanks a lot for this demo. To recognition question, try OpenCV library..

    ReplyDelete
  16. Thank you for this code.

    ReplyDelete