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

  • SEARCH
  • Home
  • 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 8819837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:27:46+00:00 2026-06-14T05:27:46+00:00

I have two CVImageBufferRef buffers that correspond to two images grabbed in sequence by

  • 0

I have two CVImageBufferRef buffers that correspond to two images grabbed in sequence by AVCaptureSession. I would like to compare both to see if all the pixels are the same. In order to loop thru all pixels of the frame buffer and compare them, I have this:

unsigned char *pixelA = (unsigned char *)CVPixelBufferGetBaseAddress(pixelBufferA);
unsigned char *pixelB = (unsigned char *)CVPixelBufferGetBaseAddress(pixelBufferB);


- (BOOL) isBuffer:(unsigned char *)pixelA equalToBuffer:(unsigned char *)pixelB {
    for( int row = 0; row < bufferHeight; row++ ) {
        for( int column = 0; column < bufferWidth; column++ ) {

            if ((pixelA[0] != pixelB[0]) ||
                (pixelA[1] != pixelB[1]) ||
                (pixelA[2] != pixelB[2]) ){
                return NO; 
                // means at some point pixelA is not equal to pixelB, so
                // pixelBufferA is not equal to pixelBufferB
            }

            pixelA += BYTES_PER_PIXEL;
            pixelB += BYTES_PER_PIXEL;

        }
    }

        // if the method reached here, pixelBufferA is equal to pixelBufferB, so
        return YES; // are equal
}

Obviously it is crashing in the comparison. How do I compare all values in pixelA with pixelB ? thanks

  • 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-06-14T05:27:47+00:00Added an answer on June 14, 2026 at 5:27 am

    I’ve never actually done what you’re doing, but is there a reason you can’t just compare the buffers in one go, say, with memcmp?

    - (BOOL) isBuffer:(unsigned char*)pixelA equalToBuffer:(unsigned char*)pixelB
    {
        size_t bufferSize = bufferWidth * bufferHeight * BYTES_PER_PIXEL;
    
        return memcmp( pixelA, pixelB, bufferSize ) == 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two queries that find both the Zip codes, and the States for
I have two richtextbox's that display stored procedures and its previous version. I would
I have two update panels on a page. And I want to update both
I have two strings like this $text = 'Abcdef'; $text[7] = 'Ghijk'; When I
I have two date fields that I need to join on. The first is
I have two columns of numbers. Both are 1 to 5. I want to
I have two algorithms, that detects AR markers (ARToolKit and Infi). I have them
Have two fields start and end, both are dates, I want to write a
Have two issues one is showFromToolbar statement format warning issue and another is that
I have two XML files. The first XML has a bunch of nodes that

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.