Question

In: Electrical Engineering

I am working on an IOT BASED HOME AUTOMATION PROJECT...I want to make use of a...

I am working on an IOT BASED HOME AUTOMATION PROJECT...I want to make use of a camera in this system to be able to capture movements or happenings in the house...
Can this be accomplished by using NODEMCU,ARDUINO,RASPBERRY PIE..
if yes...I need detailed ways on how to do it using each of them.

Solutions

Expert Solution

Its better to use Raspberry pie because it has inbuilt Camera module connector. NODEMCU and ARDUINO does not have inbuilt Camera module connector.

Connect Pi Camera to CSI interface of Raspberry Pi board

Now, we can use Pi Camera for capturing images and videos using Raspberry Pi.

Before using Pi Camera, we need to enable camera for its working.

How to Enable Camera functionality on Raspberry Pi

For enabling camera in Raspberry Pi, open raspberry pi configuration using following command,

sudo raspi-config

then select Interfacing options in which select camera option to enable its functionality.

reboot Raspberry Pi.

Now we can access camera on Raspberry Pi.

Now we can capture images and videos using Pi Camera on Raspberry Pi.

Example

Capture images and save it to the specified directory.

We can capture images using Python. Here, we will write a Python program to capture images using Pi Camera on Raspberry Pi.

Here, we have used picamera package(library) which provides different classes for Raspberry Pi. Out of which we are mainly interested in PiCamera class which is for camera module.

Python Program for Image Capture

import picamera
from time import sleep

#create object for PiCamera class
camera = picamera.PiCamera()
#set resolution
camera.resolution = (1024, 768)
camera.brightness = 60
camera.start_preview()
#add text on image
camera.annotate_text = 'Hi Pi User'
sleep(5)
#store image
camera.capture('image1.jpeg')
camera.stop_preview()

Functions Used

To use picamera python based library we have to include it in our program as given below

import picamera

This picamera library has PiCamera class for camera module. So, we have to create object for PiCamera class.

PiCamera Class

To use Pi Camera in Python on Raspberry Pi, we can use PiCamera class which has different APIs for camera functionality. We need to create object for PiCamera class.

E.g. Camera = picamera.PiCamera()

The above PiCamera class has different member variables and functions which we can access by simply inserting a dot (.) in between object name and member name.

E.g. Camera.resolution = (1080, 648)

capture()

It is used to capture images using Pi Camera.

E.g. Camera.capture(“/home/pi/image.jpeg”)

The capture() function has different parameters which we can pass for different operations like resize, format, use_video_port, etc.

E.g. Camera.capture(“/home/pi/image.jpeg”, resize=(720, 480))

resolution= (width,height)

It sets the resolution of camera at which image captures, video records and preview will display. The resolution can be specified as (width, height) tuple, as a string formatted WIDTHxHEIGHT, or as a string containing commonly recognised display resolution name e.g. “HD”, “VGA”, “1080p”, etc.

E.g.

                Camera.resolution = (720, 480)

  Camera.resolution = “720 x 480”

                Camera.resolution = “720p”

                Camera.resolution = “HD”

Annotate_text = “Text”

It is used to add text on image, video, etc.

E.g. Camera.annotate_text = “Hi Pi User”

start_preview()

It displays the preview overlay of default or specified resolution.

Example Camera.start_preview()

stop_preview()

It is used to close the preview overlay.

E.g. Camera.stop_preview()

Python Program for Video Recording

import picamera
from time import sleep

camera = picamera.PiCamera()
camera.resolution = (640, 480)

print()
#start recording using pi camera
camera.start_recording("/home/pi/demo.h264")
#wait for video to record
camera.wait_recording(20)
#stop recording
camera.stop_recording()
camera.close()
print("video recording stopped")

Functions used

We have to create object for PiCamera class. Here, we have create object as camera.

start_recording()

It is used to start video recordingand store it.

E.g. Camera.start_recording(‘demo.h264’)

It records video named demo of h264 format.

wait_recording(timeout)

Wait on video encoder for specified timeout seconds.

E.g. Camera.wait_recording(60)

stop_recording()

It is used to stop video recording.

E.g. Camera.stop_recording()

Play Recorded Video

To open video, we can use omxplayer by using following command,

omxplayer video_name


Related Solutions

I am working on an IOT BASED HOME AUTOMATION.. is there a way to control it...
I am working on an IOT BASED HOME AUTOMATION.. is there a way to control it remotely(via internet) from anywhere in the world... if yes..i need detailed way on how to do it.
Hi! I am working on a lab for Organic Chemistry and I want to make sure...
Hi! I am working on a lab for Organic Chemistry and I want to make sure my answers are correct before submitting it! Thank you in advance! Stereoisomerism: A Model Exercise In this experiment you will construct models with your molecular model set that illustrate the concepts of chirality, chiral center (stereogenic center, asymmetric carbon atom), enantiomers, diastereomers, and meso forms. You will also learn about two conventions, R-S and Fischer, for designating the configurations of chiral molecules. You will...
I am working as a cashier at Home Depot. The question is How do I use...
I am working as a cashier at Home Depot. The question is How do I use accounting in my life and my work? Does my work involve using financial accounting or managerial accounting reports?
Here is a project I am currently working on and I could use some feedback on...
Here is a project I am currently working on and I could use some feedback on how to get started. I calculated the general probabilities for the first two columns of each spreadsheet (successes / total outcomes). I don't want to move forward until I know I'm on the right track but I'm concerned that I've oversimplified the question being asked. I'm also using Excel and am having a hard time finding an appropriate formula for conditional probability. My book...
I'm working in Java and am working on a project where I need to find an...
I'm working in Java and am working on a project where I need to find an average. The catch is that for some of the values there is no data because they will be entered at a later date. I have variables assigned so that for each entry if there is an input I'll have it say _____available = 1, otherwise the variable will equal 0. I'll use an example to make this more clear. Let's say I am trying...
I am working on a project that requires a measurement of acceleration. I have a ADXL345...
I am working on a project that requires a measurement of acceleration. I have a ADXL345 accelerometer, an aduino and a MAX7219 dot matrix display. I need help setting up a code for my aduino to display the acceleration from the ADXL345 accelerometer onto the MAX7219 display. Please help!
Hey, I have a code that I am working on to make a garden plot calculator,...
Hey, I have a code that I am working on to make a garden plot calculator, however I am reaching an error that I cannot seem to get past. Please help. import math # GarednPlot contains all the utility functions class GardenPlot: # constructor function: Welcomes the user and sets default values def __init__(self): print("Welcome!") self.length = 0 self.radius = 0 self.depth = 0 # Sets the length of the GardenPlot and returns that length def setLength(self): self.length = float(input("Enter...
I am trying to solve this question: "You are working on a school project at the...
I am trying to solve this question: "You are working on a school project at the library when your friend Jane taps you on the shoulder. She cannot seem to connect to a certain website that she needs for her class. Fortunately, you know enough about Windows and networking to help troubleshoot the problem. You open a Windows command prompt and ......" The dots at the end of the story indicates that I need to continue the story. However, I...
Attached is the problem I am working on I have to use phantoms, and i have...
Attached is the problem I am working on I have to use phantoms, and i have already completed steps p and H, I need help help with step A , which is to "state and check the assumptions for the hypothesis test", I think the correct hypothesis test to use would be the 2 sample t test, but im not sure. The number of cell phones per 100 residents in countries in Europe is given in table #9.3.9 for the...
i am working on a project.. i would love to implement ENERGY METERING WITH IT SO...
i am working on a project.. i would love to implement ENERGY METERING WITH IT SO AS TO BE ABLE TO CALCULATE THE BILLS AT THE END OF A CERTAIN PERIOD.. how could this be done...BULBS,FANS,SOCKETS are the appliances involved... how can i get the energy used by all this appliances. i need very DETAILED TECHNICAL EXPLANATION.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT