2012-02-14 13 views
26

मुझे उसी कार्यक्षमता की आवश्यकता है जैसे एप्लिकेशन इंस्टेंट हार्ट रेटकैमरे का उपयोग करके हृदय गति का पता लगाना

  1. प्लेस कैमरे के लेंस पर तर्जनी के टिप धीरे:

    बुनियादी प्रक्रिया करने के लिए उपयोगकर्ता की आवश्यकता है।

  2. पूरे लेंस को भी दबाएं और कवर करें।
  3. इसे 10 सेकंड के लिए स्थिर रखें और हृदय गति प्राप्त करें।

यह फ्लैश को चालू करके और प्रकाश परिवर्तन को देखकर पूरा किया जा सकता है क्योंकि रक्त सूचकांक उंगली के माध्यम से चलता है।

मैं वीडियो कैप्चर से लाइट लेवल डेटा कैसे प्राप्त कर सकता हूं? मुझे यह कहां देखना चाहिए? मैंने कक्षा AVCaptureDevice पर देखा लेकिन कुछ भी उपयोगी नहीं मिला।

मुझे भी AVCaptureDeviceSubjectAreaDidChangeNotification मिला, क्या यह उपयोगी होगा?

+0

लेकिन आईफोन और आईपैड के गैर फ्लैश मॉडल के बारे में क्या? –

+0

@ आलोकपारीख: यदि आपके पर्यावरण में पर्याप्त प्रकाश है तो फोन फ्लैश आवश्यक नहीं है। – alinoz

+0

@alinoz कैमरा फ्लैश * कैमरा * के इस एप्लिकेशन के लिए आवश्यक है। लेंस के खिलाफ उंगली के साथ, आप अन्यथा कालापन देखेंगे। – occulus

उत्तर

3

वास्तव में सरल हो सकता है, आपको कैप्चर की गई छवि के पिक्सेल मानों का विश्लेषण करना होगा। एक साधारण एल्गोरिदम होगा: छवि के केंद्र में चयन करें और क्षेत्र, ग्रे स्केल में कनवर्ट करें, प्रत्येक छवि के लिए पिक्सेल का औसत मान प्राप्त करें और आप 2 डी फ़ंक्शन के साथ समाप्त हो जाएंगे और इस फ़ंक्शन पर न्यूनतम सीमाओं के बीच की दूरी की गणना करेंगी या अधिकतम और समस्या हल हो गई।

यदि आप 5 सेकंड की अवधि में अधिग्रहित छवियों के हिस्टोग्राम को देखते हैं, तो आप ग्रे स्तर के वितरण के परिवर्तनों को देखेंगे। यदि आप अधिक मजबूत गणना चाहते हैं तो हिस्टोग्राम का विश्लेषण करें।

+2

हाय एलिनोज़, क्या आपके लिए कुछ नमूना कोड पोस्ट करना संभव होगा? अग्रिम में धन्यवाद! – Brabbeldas

+0

@AT_AB और Brabbeldas - मैं अगले दिन एक छोटा सेटअप करने की कोशिश करूंगा। – alinoz

+1

@alinoz - क्या आपको इसके लिए नमूना प्रोजेक्ट/कोड डालने का मौका मिला? अगर आप एक साथ कुछ डालते हैं तो हमें बताएं –

25

चेक बाहर इस ..

// switch on the flash in torch mode 
if([camera isTorchModeSupported:AVCaptureTorchModeOn]) { 
[camera lockForConfiguration:nil]; 
camera.torchMode=AVCaptureTorchModeOn; 
[camera unlockForConfiguration]; 
} 

    [session setSessionPreset:AVCaptureSessionPresetLow]; 

    // Create the AVCapture Session 
    session = [[AVCaptureSession alloc] init]; 

    // Get the default camera device 
    AVCaptureDevice* camera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 
    if([camera isTorchModeSupported:AVCaptureTorchModeOn]) { 
    [camera lockForConfiguration:nil]; 
    camera.torchMode=AVCaptureTorchModeOn; 
    [camera unlockForConfiguration]; 
} 
// Create a AVCaptureInput with the camera device 
    NSError *error=nil; 
    AVCaptureInput* cameraInput = [[AVCaptureDeviceInput alloc] initWithDevice:camera error:&error]; 
    if (cameraInput == nil) { 
    NSLog(@"Error to create camera capture:%@",error); 
    } 

    // Set the output 
    AVCaptureVideoDataOutput* videoOutput = [[AVCaptureVideoDataOutput alloc] init]; 

    // create a queue to run the capture on 
    dispatch_queue_t captureQueue=dispatch_queue_create("catpureQueue", NULL); 

    // setup our delegate 
    [videoOutput setSampleBufferDelegate:self queue:captureQueue]; 

    // configure the pixel format 
    videoOutput.videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber  numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey, 
    nil]; 
    // cap the framerate 
    videoOutput.minFrameDuration=CMTimeMake(1, 10); 
    // and the size of the frames we want 
    [session setSessionPreset:AVCaptureSessionPresetLow]; 

    // Add the input and output 
    [session addInput:cameraInput]; 
    [session addOutput:videoOutput]; 

    // Start the session 

    [session startRunning]; 

    - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { 



    // this is the image buffer 

    CVImageBufferRef cvimgRef = CMSampleBufferGetImageBuffer(sampleBuffer); 


    // Lock the image buffer 

    CVPixelBufferLockBaseAddress(cvimgRef,0); 


    // access the data 

    int width=CVPixelBufferGetWidth(cvimgRef); 
    int height=CVPixelBufferGetHeight(cvimgRef); 


    // get the raw image bytes 
    uint8_t *buf=(uint8_t *) CVPixelBufferGetBaseAddress(cvimgRef); 
    size_t bprow=CVPixelBufferGetBytesPerRow(cvimgRef); 


// get the average red green and blue values from the image 

float r=0,g=0,b=0; 
for(int y=0; y<height; y++) { 
for(int x=0; x<width*4; x+=4) { 
    b+=buf[x]; 
    g+=buf[x+1]; 
    r+=buf[x+2]; 
} 
buf+=bprow; 
} 
    r/=255*(float) (width*height); 
    g/=255*(float) (width*height); 
    b/=255*(float) (width*height); 

    NSLog(@"%f,%f,%f", r, g, b); 
    } 

नमूना कोडHere

+3

यह कोड केवल ग्राफ देता है। लेकिन 100 बीपीएम की तरह हृदय गति के बीपीएम मूल्य प्राप्त करने के पीछे तर्क क्या है। कोई उपाय? – coder1010

+2

वही कोड लिंक टूटा हुआ है। कृपया – Viper

3

एक तरफ ध्यान दें के रूप में, आप this research paper में रुचि हो सकती। इस विधि को सीधे लेंस पर एक उंगली (या कुछ भी) की आवश्यकता नहीं होती है।

+3

को ठीक करें, यह लेख पेटेंट लंबित शोध है, यदि आपके लिए महत्वपूर्ण है – toolbear

+0

क्या आप पेटेंट या लंबित होने का संदर्भ दे सकते हैं? – AlexK

संबंधित मुद्दे