Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming you want to do this in real time (rather than using a screen capture, which you specifically say you <em>don't</em> want):</p> <p>You first need to be capturing the video buffer <strong><a href="http://developer.apple.com/library/ios/#qa/qa1702/_index.html" rel="noreferrer">as outlined by Apple here</a></strong>. </p> <p>Then you can do what you like with the <code>CMSampleBufferRef</code>. Apple's sample app makes a <code>UIImage</code>, but you can simply copy it across into an <code>unsigned char</code> pointer (via a <code>CVImageBufferRef</code> or <code>CVPixelBufferRef</code>) and then pull the BGRA value of the pixel in question, something like this (untested code: example is for the pixel at 100x,200y):</p> <pre><code>int x = 100; int y = 200; CVPixelBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); CVPixelBufferLockBaseAddress(imageBuffer,0); tempAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer); size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer); size_t width = CVPixelBufferGetWidth(imageBuffer); size_t height = CVPixelBufferGetHeight(imageBuffer); CVPixelBufferUnlockBaseAddress(imageBuffer,0); int bufferSize = bytesPerRow * height; uint8_t *myPixelBuf = malloc(bufferSize); memmove(myPixelBuf, tempAddress, bufferSize); tempAddress = nil; // remember it's BGRA data int b = myPixelBuf[(x*4)+(y*bytesPerRow)]; int g = myPixelBuf[((x*4)+(y*bytesPerRow))+1]; int r = myPixelBuf[((x*4)+(y*bytesPerRow))+2]; free(myPixelBuf); NSLog(@"r:%i g:%i b:%i",r,g,b); </code></pre> <p>This gets the position relative to the pixels of the video feed itself, which may not be what you want: if you want the position of the pixel as displayed on iPhone's display, you may need to scale this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload