Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6125211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:13:18+00:00 2026-05-23T16:13:18+00:00

I need to do an iphone app that can look for a image pattern

  • 0

I need to do an iphone app that can look for a image pattern in an image. (sth like this)

After numerous google searching, i feel that the only option i have in to use template matching function in the opencv which has been ported for objectiveC.

I found an excellent starting point for a simple opencv project in objectiveC from this github code.

But it is only using edge detection and face detection features in the openCV. I need an objectiveC example that uses the template matching function – “cvMatchTemplate” – in objectiveC for iPhone?

Below is the code I have at this moment: (at least it is not giving me error, but this piece of code, return a completely black image, i am expecting a result image where matched area will be brighter?)

    IplImage *imgTemplate = [self CreateIplImageFromUIImage:[UIImage imageNamed:@"laughing_man.png"]];
    IplImage *imgSource = [self CreateIplImageFromUIImage:imageView.image];        
    CvSize sizeTemplate = cvGetSize(imgTemplate);
    CvSize sizeSrc = cvGetSize(imgSource);       
    CvSize sizeResult = cvSize(sizeSrc.width - sizeTemplate.width+1, sizeSrc.height-sizeTemplate.height + 1);
    IplImage *imgResult = cvCreateImage(sizeResult, IPL_DEPTH_32F, 1);
    cvMatchTemplate(imgSource, imgTemplate, imgResult, CV_TM_CCORR_NORMED);
    cvReleaseImage(&imgSource);
    cvReleaseImage(&imgTemplate);        
    imageView.image = [self UIImageFromIplImage:imgResult];
    cvReleaseImage(&imgResult);

p/s: Or, should I try to recognize object using cvHaarDetectObjects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:13:18+00:00Added an answer on May 23, 2026 at 4:13 pm

    The result from cvMatchTemplate is a 32-bit floating point image. In order to display the result, you’ll need to convert that to an unsigned char, 8-bit image (IPL_DEPTH_8U).

    The CV_TM_CCORR_NORMED method produces values between [0, 1] and cvConvertScale provides an easy way to do the scaling and type conversion. Try adding the following to your code:

    IplImage* displayImgResult = cvCreateImage( cvGetSize( imgResult ), IPL_DEPTH_8U, 1);    
    cvConvertScale( imgResult, displayImgResult, 255, 0 );
    imageView.image = [self UIImageFromIplImage:displayImgResult];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an iPhone app that can save email attachments. I would like
We have an iPhone app that can display an image dataset and pass it
For an iPhone app that submits images to a server I need somehow to
I am building an iPhone app that will need to display info primarily in
Let's say I need to access a web service from an iPhone app. This
(This algorithm is for an iPhone app I am working on, if that helps
OK, I have a screen in my iPhone app that looks like the following:
In an iPhone app, I need to customize the look of a UINavigationController class.
I'd like to write an iPhone app that packs the contents of a website
I need to create an iPhone/Mac app that is in a non-English language only.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.