Coffee Watcher solution is based on image recognition, this post will show how the Canvas App is developed. Most secure and compliant solution for production use would be use wifi camera, that sends image every minute i.e. to email address. But I did not have it and wanted to test my idea, I created Power Apps Canvas App and my old mobile phone for testing it.
1. Go to Maker Portal and to navigate to solutions
2. Create new solution
3. Add existing item AI Model which you created in previous post
4. Create new App -> Canvas app
Add there following controls: Camera, Drop down, Timer and Image.
5. Modify drop down control
6. Modify camera control
7. Close the app and re-open
This is for getting the new stream rate working
8. Add the OnStart of the App
Create global variables selectedCamera, varMessageId and wasFull for the app to use
9. Modify the Timer control
Select the control and set duration, repeat, auto start and auto pause
Add to the OnTimerStart property the following code.
Code will get a screenshot of the camera stream when the timer starts and sends it for further processing via Power Automate flow which we will be implementing in the next post. The code will send picture to flow and then get information was the coffee pot full and message id.
Message id will be used for updating the same Teams adaptive card instead of creating new one every minute. WasFull is used in the flow understandin, when to inform in chat when there is new coffee, so that it does not inform it every minute as new message as long as there is full coffee pot detected in the picture.
UpdateContext({varPhoto:Camera1.Stream}); ClearCollect(PictureColl, varPhoto); If(!IsBlankOrError(varPhoto), IfError( // Try Set(response, ProcessPictureandInformOthers.Run(wasFull, varMessageId, { file: { contentBytes: First(PictureColl).Value, name: "anyname.jpg" } })); , // Catch // Reset the variables Set(varMessageId, "0000"); Set(wasFull, false); ); Set(varMessageId, Text(response.messageid)); Set(wasFull, response.isfull); ) //Notify("Kuva lähetetty tulkittavaksi", NotificationType.Success);
Other posts in this solution
- Solution presentation “Is there and coffee left”
- Teaching custom AI model for object detection
- Power Apps Canvas to capture picture every minute
- Solution architecture and trigger errors
- Flows to use Object Detection and informing of fresh Coffee
- Adaptive card updating every minute with thumbnail picture