Taking a Selfie with USB cam on MagicMirror. (Pi CAM will be supported later.)
[1.0.3] - 2020-06-02
- Added: Feature to put a touch-enabled icon to take a selfie.
[1.0.2] - 2020-03-23
- Added: Feature for showing last taken selfie.
- TelegramBot command
/lastselfie
- Notification:
SELFIE_LAST
- Notification:
- TelegramBot command
- Added: Notification for shooting result.
SELFIE_RESULT
with payload{uri, path}
[1.0.1] - 2020-03-23
- Added: Can upload photo to specific google photos via MMM-GooglePhotos(> v2.0.0)
- For Raspbian / Linux
sudo apt-get install fswebcam
- For Mac OSX
brew install imagesnap
cd <YOUR_MAGIC_MIRROR_DIRECTORY>/modules
git clone https://github.com/eouia/MMM-Selfieshot
cd MMM-Selfieshot
npm install
This module doesn't need
position
of module unless you're using the touch button.
{
disabled: false,
module: "MMM-Selfieshot",
config: {}
}
To place a button on the mirror that you can click or touch, you will have to include a position and the name of the Font Awesome icon.
{
disabled: false,
module: "MMM-Selfieshot",
position: "bottom_left",
config: {
displayButton: "portrait"
}
}
These values are set as default, you don't need to copy all of these. Just pick what you need only and add it into your
config:{}
debug: false, // You can get more detailed log. If you have an issue, try to set this to true.
storePath: "./photos", // No need to modify.
width:1280,
height:720, // In some webcams, resolution ratio might be fixed so these values might not be applied.
quality: 100, //Of course.
device: null, // `null` for default camera. Or,
// device: "USB Camera" or "/video/video11" <-- See the backend log to get your installed camera name.
shootMessage: "Smile!",
shootCountdown: 5, // 5,4,3,2,1,0 then shutter.
displayCountdown: true,
displayResult: true,
playShutter: true,
shutterSound: "shutter.mp3",
useWebEndpoint: "selfie", // This will activate 'https://YOUR_MM_IP_OR_DOMAIN:PORT/selfie [POST]' as web API endpoint.
resultDuration: 1000 * 5,
sendTelegramBot: true,
sendMail: null, // or your email config (option for nodemailer https://nodemailer.com/about/)
width
&height
: In some environment, resolution would be fixed so these value couldn't affect.
If you want to send a photo taken through mail, set for your environment like this example.
sendMail: {
transport: {
host: 'smtp.gmail.com', // If required.
port: 465, // If required.
secure: true, // If required.
auth: {
user: "[email protected]",
pass: "your gmail password"
}
},
message: {
from: "[email protected]",
to: "[email protected]",
subject: "Selfie",
text: "New selfie.",
}
}
- For details; read https://nodemailer.com/about/
- Your firewall could block mail. Check your network status.
- Use alternative than gmail. Above is just an example.
- Or any PR will be welcome to make this things simple.
- by
notification
SELFIE_SHOOT
- Your other module can make an order to take a picture (Button, Voice Commander, Sensors,...)
this.sendNotification("SELFIE_SHOOT")
//or
this.sendNotification("SELFIE_SHOOT", {
option: {
shootCountdown: 1,
displayResult: false,
playShutter: false,
displayCountdown: false,
// only these 4 properties are available.
}
})
//or
this.sendNotification("SELFIE_SHOOT", {
option: { ... },
callback: (result) => {
console.log(result) // It will have result.path and result.uri
this.doSomething(result)
}
})
SELFIE_EMPTY_STORE
: You can remove all photos in store directory.SELFIE_LAST
: You can display last photo taken on screen.
- by
MMM-TelegramBot
/selfie
or/selfie 5
: Take a photo (with countdown)/emptyselfie
: Remove all photos/lastselfie
: Display last the last photo taken on screen and telegram.
- by
HTTP Request
- This will activate 'https://YOUR_MM_IP_OR_DOMAIN:PORT/selfie [POST]' as web API endpoint.
- If you don't need this, set it to
null
.
CURL example;
curl -d '{"shootCountdown":7}' -H "Content-Type: application/json" -X POST http://localhost:8080/selfie
You can use this feature for IFTTT or other program out of MagicMirror.
-
Photos will be stored in
/photos
directory. You can usersync
or any tools to share/send/sync with other storage. (Ask to your network/system admin.) -
by
MMM-GooglePhotos
- Photos will be uploaded to Google Photos album automatically.
- Native Pi camera support. (I have no pi camera at this moment, so I can't implement. Or, any PR will be welcome.)