AR(Augmented reality) framework for iOS, based on a visual code like ARToolKit
C C++ Objective-C Matlab
Latest commit 7e4be79 Feb 16, 2012 @sonsongithub Improved Makefile.
Supported debug symbols.
Delete dsym file automatically.
Failed to load latest commit information.
c++ Improved Makefile. Feb 16, 2012
c Added default and icon image to C sample project, too. Sep 26, 2011
matlab Added MATLAB code to detect 4 corners with a new algorithm. Jan 16, 2012
resource Added MATLAB code to detect 4 corners with a new algorithm. Jan 16, 2012
.gitignore Added the code to check whether the blob is convex. Dec 5, 2011
LICENSE Updated Feb 11, 2012


Introduction and information

CoreAR.framework is open source AR framework. You can make an AR application using visual code like ARToolKit using this framework. CoreAR.framework does not depend on the other computer vision library like OpenCV. Considered portability, this framework is written only C or C++. The pixel array of an image is passed to CoreAR.framework and then visual code's identification number, rotation and translation matrix are obtained from the image including a visual code. Image processing speed of this framework is about 15 fps on iPhone4.

Take notice that CoreAR.framework depends on Quartz Help Library and Real time image processing framework for iOS. You have to download these libraries and put on them at the path where CoreAR.framework has been installed.


BSD License.

App Store

You can take a sample application from App Store.

Sample code in C++

float codeSize = 1;
int croppingSize = 64;
int threshold = 100;
int width = (int)bufferSize.width;
int height = (int)bufferSize.height;

// do it
if (chaincodeBuff == NULL)
    chaincodeBuff = (unsigned char*)malloc(sizeof(unsigned char) * width * height);

// binarize for chain code
for (int y = 0; y < height; y++)
    for (int x = 0; x < width; x++)
        *(chaincodeBuff + x + y * width) = *(buffer + x + y * width) < threshold ? CRChainCodeFlagUnchecked : CRChainCodeFlagIgnore;

// prepare to parse chain code
CRChainCode *chaincode = new CRChainCode();
chaincode->parsePixel(chaincodeBuff, width, height);

// clear previous buffer
CRCodeList::iterator it = codeListRef->begin();
while(it != codeListRef->end()) {

// reload detected codes
if (!chaincode->blobs->empty()) {
    std::list<CRChainCodeBlob*>::iterator blobIterator = chaincode->blobs->begin();
    while(blobIterator != chaincode->blobs->end()) {
        if (!(*blobIterator)->isValid(width, height)) {
        CRCode *code = (*blobIterator)->code(); 
        if(code) {
            // estimate and optimize pose and position
            code->normalizeCornerForImageCoord(width, height, focalLength, focalLength);

            // cropping code image area
            code->crop(croppingSize, croppingSize, focalLength, focalLength, codeSize, buffer, width, height);

Sample code in C (depracted)

// Copy image buffer from camera into "pixel".
int width;
int height;
unsigned char *pixel = (unsigned char*)malloc(sizeof(unsigned char) * width * height);

// codeInfoStorage receives the result of visual code recognition.
CRCodeInfoStorage *codeInfoStorage = CRCreateCodeInfoStorage();

// storage to save visual code templates.
CRCodeImageTemplate *codeImageTemplateStorage = CRCreateCodeImageTemplateStorage();

// make template to recognize visual codes.
int c_width;
int c_height;
unsigned char *c_p = (unsigned char*)malloc(sizeof(unsigned char) * c_width * c_height);

/* read images of visual codes you want to recognize */

CRCodeImageTemplate *template = CRCreateCodeImageTemplate(c_p, c_width, c_height);
template->code = codeNumber;
template->size = codeSize;
CRCodeImageTemplateStorageAddNewTemplate(codeImageTemplateStorage, template);

// Start extraction
CRChainCodeStorage *storage = CRCreateChainCodeStorageByParsingPixel(pixel, width, height);
CRCodeInfoStorageAddCodeInfoByExtractingFromChainCode(codeInfoStorage, storage, valueBuffer, width, height, codeImageTemplateStorage);

// Release

Frequently Asked Questions

  • I can't compile CoreAR.framework...

  • How do I render a 3D model on the code with CoreAR.framework?

    • Ans. CoreAR.framework does not support rendering any 3D model files. You have to write a code to render 3D model files with OpenGLES. Sample program does not render a cube and Utah teapot with 3D model files but with OpenGLES code.