Upload reference image module code

Now, we write the main modules for uploading the reference image, where the IR sensor detects the presence and triggers Pi to capture the image, and send it to S3, and then to Rekognition to be stored in the collection.

Create a file with the name UploadImageIR.js and add the following code:

var GPIO = require('pigpio').Gpio,

cameraModule = require('./CameraModuleRekognition'),

s3Bucket = require('./S3Put'),

green_LED = new GPIO(19,{mode: GPIO.OUTPUT}),

red_LED= new GPIO(17,{mode: GPIO.OUTPUT}),

IR_out= new GPIO(5,{mode: GPIO.INPUT,alert: true});

red_LED.digitalWrite(0);

green_LED.digitalWrite(0);

IR_out.on('alert', function(level, tick){

if(level==1){

cameraModule.takePicture(function (callback) {

var result = callback;

if(result == 'success'){console.log('success...!!')

}

})

console.log('IR : Imaging you..!!')

red_LED.digitalWrite(level);

}

else {

red_LED.digitalWrite(level);

buzzer.digitalWrite(level);

}

})
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.240.178