Hello, makers! In our blog post today, I wanted to share a simple way to remotely control IoT devices using NodeJs and Google Firebase. Let’s say you’re trying to remotely control a small lego crane like this. You’ll notice there are two servo motors connected to an Arduino. You can learn more about how you can build this in our post on Arduino and Lego motor control. For the scope of this blog post, let’s say we wanted to remotely control the servo motor at the bottom from any place in the world. How would we do that?
I started to wonder if we could connect Johnny 5 to the real-time database of Firebase. What’s a real-time database? In a traditional relational database like MySQL, you need to declare database tables and structures. You can make a database table to store a list of persons and their addresses (see sample code here). After doing that, you can insert data into that table. In this traditional database world, you can’t listen for inserts into a database table and easily write code to reach to that event.
The Firebase real-time database organizes information in a tree structure. You can store information in that tree any way that you want. Other users who have access to the database can listen for data changes at various locations in the tree and write code to react to that event. Check out the following video to learn how the Firebase Real-time database works. Especially listen to how the value change event works.
In science fiction, we have dreamed about the days when we’ll talk to our computers to make things happen. In Star Trek, crew members can talk to the Holodeck computer to “program” and explore amazing virtual experiences. Tony Stark(aka. Ironman) constantly gets situation awareness from Jarvis during battle by simply talking to his device. We’re still a long way away from Holodecks, R2D2, and Ironman. As developers and makers, we can explore the potential of voice interactions with mobile devices today.
The Google Actions toolkit enables you to integrate your services into the voice command interface of a Google assistant. This technology touches millions of devices including phones, cars, and assistant devices. You can also integrate into services provided by Google or third party services.
This past weekend, our local Google developer group of Central Florida organized a hackathon to explore applications of voice user interfaces and Google Actions. We enjoy getting to organize community workshops like this. Love seeing our community come together. It’s always a great opportunity to learn, meet people, and generate new ideas.
In general, Google actions work well in three major use cases. Users on the go. People starting their day. People relaxing at the end of the day. For my Google Actions app, I tried to think of an application of Google Actions that would support our leadership team for our GDG. We recently adopted a Trello board to help us organize tasks for our club. If you’re not familiar with Trello, it’s simple a task management system popular with Agile teams. ( see a screenshot below ) As a busy Dad and professional, I typically think of stuff that needs to be accomplished for the GDG while I’m driving.
I decided to create a simple Google Action to enable me to collect a task and share it on our leadership Trello board. I tried to explore this task in three phases.
1. Get to know the Google Actions API: I used a variety of resources to get to know the Google Actions interface. I, however, found this code lab very helpful. After doing this code lab, I was able to slightly elaborate on the tutorial to create my own stuff.
2. Build Trello integration code to add a task to a list: On my local laptop, I started playing around with a few options for adding task information to a list. I found the “node-trello” package for NodeJs worked really well.
3. Integrate the Google Actions API and the NodeJS code together
Ok, Google. Let me talk to GDG tasks
The system replies with a greeting and a prompt for a command
The user can reply “add task.”
In this intent, we can configure the system to respond to similar phrases to “add task.”
At this point, the intent collects two pieces of information. (task name and task details). We configure the intent to fulfill the conclusion of the intent with custom code.
Hope this code sample helps you understand the experience of building a Google Actions application.
Here’s a few more resources and ideas to help you write your own Google Actions app.
In my view, one of the best educational and community hacks of all times is the library. Why? They are organizations devoted to growing minds through books. Books have the ability to send us to new worlds of adventure, help us consider diverse perspectives, and exercise our imagination. Today, I wanted to introduce you to one of my best friends from church and expert homeschool teacher, Lisa Twardowski. She has amazing, thoughtful and talented kids. We enjoy getting our families together to do maker education projects. I really appreciated her post on the empathy you learn from books. Hope you enjoy it.
As I sit sipping my hot tea after I have tucked my children into bed, I ponder the questions they asked during our nightly read aloud. While the youngest, our daughter, was still brushing her teeth, I began reading, “The Dangerous Book of Heroes” to our boys. They opted for an entry entitled, “The Abolition of Slavery in England”. As soon as we started the story, the boys said we would need to stop before their sister joined us, but it was too late. She was already in tears in the other room, asking how one person could possibly feel like they had the right to own or sell another person – a human being!? One of her brothers explained that that is just the way the world is, while the other brother tried to explain that it is not okay and no one should do it.
We all opted to move on to our family read aloud, “Little House on the Prairie”. Safe, I mistakenly thought. The title of the chapter we were reading, “The Tall Indian”. In this chapter, Laura describes her mother’s disgust at the Indians who are using the well-worn trail that is near their new home in Missouri. Pa mentions that if he had known that trail was the Indian highroad, he never would have built his home so close to it. Laura asks question after question about the Indians: why will they have to move west (because the government will make them) and isn’t this their territory (yes, but white men are moving here now).
The topics, so unfamiliar to us today – at least to my young children – were upsetting, thought-provoking, and cause for pause and reflection. They felt empathic; they have the ability to imagine or share the feelings of another.
Empathy is something that cannot be taught, it must be understood, lived, experienced. One person cannot live in every situation, so how do we “learn” empathy? TV isn’t working; computer games aren’t working; apps – as great as they are, aren’t getting the job done. What is a mom or dad to do – our future generation is at stake! Empathy is now one of the Top 10 Skills employers are looking for in their new hires. Why? Because so many of our young people today are not able to put themselves in a situation outside of the one they are living.
So, how do we solve this problem of learning to be empathic? It’s as simple as words in print: Books. Do you remember those? A stack of bound paper with words and sometimes pictures printed in ink, some with a funny smell. It’s the words printed on those pages that are the important part of this story. Sure, now you can read the printed word on a screen, and even get the sounds effects of turning a page – which works just fine too, but it is those words. It’s the words that tell the stories of lives and journeys and events that the reader can never live, but can experience through those written words. The reader can become familiar with characters, and practices, and locations that they may never get to visit – or that no longer exist except through that written word.
Reading is a big deal these days. Sometimes we think reading is the magic key that will unlock any door. And while I am certainly a believer that reading can fix many of our problems, I do think it is VERY important to choose what we, and our children, are reading carefully. Captain Crazy Cape is not going elicit more than crass humor from our children. Diary of Anyone is probably not worth our time. What goes in will come out – it works in the stomach and the brain.
There are some great book recommendations online – and what you will find after reading enough of those lists is that as that they contain a lot of the same books. Not all the books are old, but those tend to be the ones most often turned to. Some of the books I have read recently that really stirred me are middle-grade novels, many written in the 1950s. The following is not a complete list, as I don’t believe such a thing can exist, but any of these books are a good place to begin.
Little House on the Prairie Series
Sarah, Plain, and Tall
The 100 Dresses
Number the Stars
Amos Fortune, Free Man
The Secret Garden
Carry On, Mr. Bowditch
Where the Red Fern Grows
Island of the Blue Dolphin
Shipwreck at the Bottom of the World: The Extrodinary True Story of Shackleton and the Endurance
Roll of Thunder, Hear My Cry
Men of Iron
The Bronze Bow
The Giver (Upper Middle School, High School, and Adult)
Silas Marner (Upper Middle School, High School, and Adult)
The Strange Case of Dr. Jekyll and Mr. Hyde (High School and Adult)
The Hiding Place (a must read for ALL High School students and Adults)
There is no magic fix all in any of these books. Some are true accounts of the authors’ lives, some are historical fiction, and still, others are fiction outright. All tell the story of humankind: the hardship and failures, the successes and joys. Each will allow the reader to walk a mile in another person’s shoes. These stories span historical times, locations, race, and socio-economic classes, but they all deal with characters who struggle with one issue or another, but find hope to continue on.
Most of these situations are not things we can even offer our children, nor would we want to: to become an orphan, or a slave, or a science experiment. But they can see life through another’s eyes and learn what it may have been like to have those struggles, and think those thoughts, and possibly make different choices – or at least ponder, “what would I have done?” To be empathic to another’s struggles and life. To gain the ability to imagine or share in the feelings of another, all from the safety of the sofa.
As LeVar Burton of Reading Rainbow so often reminded us, “But you don’t have to take my word for it…”
In our modern world of mobile devices and tech, it’s easy to become distracted. As knowledge workers, we have an attraction to achieve mastery in our craft and autonomy. My family will attest that I do a lot of “work related” or “blog related” reading to stay on top of the latest maker tools, trends or leadership coaching. Our mobile devices offer an escape. They offer infinite entertainment, infinite knowledge, and illusion of being connected. Without checks and balances, is it worth the cost?
As I draft this post, I know that I can own the challenge of being more present to my friends, family and peers. As a Dad and husband, I am challenging myself to be in the moment. Honestly, this is a struggle. I work as a software engineer. Many programmers(including myself) will confess that they have the ability to continue working problems in their head even after they’ve disconnected from their computers. Now that we’re armed with mobile phones and Google, we can continue to “research” solutions anytime and anywhere. I know I have to cherish my wife and kids. My kids will only be little once in a lifetime. Let’s make this time count.
On a professional level, our team leader purchased our team the gift of really nice notebooks during a sprint planning meeting. After handing out theses gifts to each team member, he invited us to close our laptops/devices to encourage us to engage more deeply in the meeting and with each other. The message was the same. Let’s be present to each other. Since that teaching moment has happened, I’ve noticed that our team members have become more prepared to meetings too. This has increased meeting effectiveness. In some ways, this teaching hints at the agile concept of “people over processes and tools.”
As mentioned before, I struggle with the distraction of mobile tech just like anyone else. I believe that making, tinkering, and engineering skills support a profound engagement in learning. As my friend Sylvia Martinez says, “making is a stance toward learning.” Technology is one tool of many to express creativity and grow. It’s not the only tool. I have to acknowledge the tech needs limits, balance, and bounds. The following video by Guy Raz from NPR motivated me to draft this post. My goal in sharing this post is simply to create awareness of the influence of mobile tech. How do we use this tool effectively? How do we keep this technology in balance? How do we become more present to the people around us?
Do you have any rules of thumb that you follow to be more present? We love to hear from our readers. Please share a comment below.
Whether you’re just starting in your career or you’ve been working in the industry for years, you can benefit from the culture and practice of open source. I want to thank John Baluka for sharing his reflections and personal journey on this topic. I really appreciate John’s fresh business perspective on using open source to advance your learning and business. I had the opportunity to hear him share his talk on this topic during an ONETUG meeting this past week. If you’re in the Orlando area, make sure to check out ONETUG. They’re a great community of programming professionals.
I believe that John hit on 5 thoughtful benefits for getting to know open source solutions. In John’s view, you need to be strategic on your investment of time.
1. Personal learning and growth: In John’s journey, he wanted to find an example of a large software architecture written in .NET and ASP.NET MVC. He selected NopCommerce, a cool e-commerce platform for .NET developers. John organized lessons and meta-patterns from dissecting this project into a talk. Some of the topics included dependency injection, language localization, data validation, plug-in architecture, and agile design. John offered us a challenge to select and study an open source project as a tool to advance your career in architecture or software leadership. On InspiredToEducate.NET, we have talked about this principle in the context of the makers movement. Everyone can learn something from reading code, exploring a 3D model, dissecting an electronics schematic, music, art, etc. What’s an open source project that fits into your space of passion?
2. Open source software enhances your public profile of work: When you hire an interior designer, how would you make your decision? You probably would review pictures of previous work to see if the designer fits with your tastes and requirements. For the average job interview in software engineering, it’s typically hard to show code from your previous gig. (i.e. corporate secrets, policies) Most companies don’t do their work in open source. By getting involved and contributing to an open source project, you can enhance your public profile of work. How does your GitHub reflect your strengths and skills?
3. Speed to solution: It’s important to remember that software developers aren’t paid to write code. We provide value and solve business problems. Open source software enables our teams to reduce time to market. Phil Haack, creator of ASP.NET MVC and engineer at GitHub, shared a reflection that businesses should always focus on their unique value proposition. (i.e. what makes your company different than other options ) Open source provides an opportunity for companies to partner or collaborate on elements outside of your unique value proposition. Why write a big workflow system or content system when you can integrate one?
4. Open source is social: To advance your career, it’s important to expand your network and relationships. Growing authentic relationships becomes critical in growing your business. By collaborating on open source, you have an opportunity to learn from others. You have the opportunity to invest and support peers around you. I personally get excited about supporting the growth of others.
5. Business models around open source software: I really appreciate John’s reflections on this aspect. I admire his pragmatic approach to selecting NopCommerce. On one level, the open source project followed good and clean patterns. In his view, the project isn’t perfect, but you can learn something from it. By sharing his reflections on the software design during user group meetups and conferences, he started getting consulting requests to support NopCommerce integrations. He challenged us to strategically select an open source project for learning with an eye toward job growth. In the NopCommerce space, you can earn money by building store themes, building plugins, providing support or integrations. Here’s a few more blog post that elaborate on this idea.
Google I/O is an annual software developer-focused conference which features a keynote on the latest updates and announcements by Google. The conference also hosts in-depth sessions focused on building web, mobile, and enterprise applications with Google and open web technologies such as Android, machine learning, TensorFlow, Chrome, Chrome OS, Google APIs, Google Web Toolkit, and App Engine.
In this blog post, I’m going to share my favorite announcements from the conference. Hope these items serve makers, app developers, and web developers.
Abstract: Angular has a flag that will cut hundreds of kilobytes off of your bundles, improve mobile experiences, and allow you to dynamically create components on the fly. Learn about these changes and what they mean for your applications.
Android Studio 3.2
Google has worked to improve the application model for Android for simplicity, power, and developer speed. I’m curious to test the speed of the new Android emulator.
Abstract: The last couple of years have seen a plethora of new features and patterns for Android developers. But how do developers know when to use existing APIs and features vs. new ones? This session will help developers understand how they all work together and learn what they should use to build solid, modern Android applications.
For our makers and tinkering readers, you might check out Google AIY projects. I find it interesting that you can go to your local Target store and pick up a Google AIY kit so that you can start experimenting with machine learning, voice control, and computer vision.
Abstract: AIY efforts at Google puts AI into various maker toolkits, to make things more playful and, more importantly, to help you solve real problems that matter to you and your communities. Join this session to learn how you can use these kits to start adding natural human interaction to your maker projects. It will feature demos on the Voice and Vision Kits, and some amazing AIY experiments built by the makers community around the world.
Abstract: Come watch a single developer code a beautiful app in real-time from the ground-up that runs natively on iOS and Android, all from a single codebase. Along the way, learn how to marry Flutter’s latest multi-platform reactive UI elements, accelerometer, and audio capabilities with powerful Firebase SDK functionality. See this app painted to life piece-by-piece in under 40 minutes thanks to Flutter’s sub-second hot reload developer experience.
Google’s ARCore framework received several notable updates. Firstly, Google ARCore enables developers to write Android apps that sense your environment. With these capabilities, developers can place 3D content layered over a view of the real world. This technology unlocks an amazing class of games, collaboration, and design applications that serve users in their physical spaces. The first version of Google ARCore focused on horizontal surfaces. Google has upgraded ARCORE to sense vertical surfaces(walls) and pictures. (i.e. custom tracker markers) Google now offers a way to shared markers or points of interest with multiple users. Let’s say you’re making an AR pool game using your dining room table. Multiple players of your game can collaboratively target the same dining room table and participate in a shared game experience. It should be noted that you can “instant preview” ARCore apps using ARCore Unity tools. This really helps you reduce your iteration cycles.
Abstract: Learn how to create shared AR experiences across iOS and Android and how to build apps using the new APIs revealed in the Google Keynote: Cloud Anchor and Augmented Images API. You’ll come out understanding how to implement them, how they work in each environment, and what opportunities they unlock for your users.
What’s new on Android on ChromeBooks
On InspiredToEducate.NET, we’re passionate about serving students, teachers, and makers of all ages. Since my wife works as a college professor, we’re constantly geeking out over various tools in educational technology. It’s very clear that Chrome books have made a positive impact in K-12 education. According to this article, Google Chromebooks command 58% of laptop devices in the K-12 market. That translates to millions of devices. It’s cool to see Google expand the capabilities of Google Chromebooks using their innovations in Android.
Abstract: With the Play Store on Chromebooks gaining traction, developers need to understand how to build high-quality apps and content for the new form factor. Attend this session to learn about adding support for larger screens, mouse and trackpad support, keyboard support (i.e. shortcut keys), free-from resizable windows, and stylus support for devices that have them.
Abstract: Android Things is Google’s platform to support the development of Internet of Things devices. This talk will provide an update on the program and the future roadmap. Learn more about the breadth of hardware reference designs, the operating system, building apps, device management, and support from chip vendors. It will also discuss use-cases where edge computing can be used, and examples of prototype-to-production that demonstrate how Android Things is ready for commercial products.
Abstract: Sceneform SDK is a new library for Android that enables the rapid creation and integration of AR experiences in your app. It combines ARCore and a powerful physically-based 3D renderer. In this session, you’ll learn how to use the Sceneform SDK, and how to use its material system to create virtual objects that integrate seamlessly with the environment.
Over the years, Google has focused their energy on advancing machine learning capabilities. They have now entered a phase where application developers can now weave the power of machine learning brains(machine learning models) into their applications. Google TensorFlow enables app developers to train powerful neural network models so that computers can learn and use that intelligence in applications. In Google photos, I can do weird searches like “flowers in macon, ga.” Since Google have fast neural networks that can I identify flowers, Google can quickly return a list of photos with flowers matching my expectations. Wouldn’t it be cool if you could put these capabilities into your Raspberry Pi or Android app? TensorFlow Lite enables you to leverage pre-trained TensorFlow models in your apps. I’m very impressed by their focus on speed and efficiency.
Abstract: TensorFlow Lite enables developers to deploy custom machine learning models to mobile devices. This technical session will describe in detail how to take a trained TensorFlow model, and use it in a mobile app through TensorFlow Lite.
The following video demo’s some of Google’s cool innovations in computer vision. Using Google Lens, the photos app can identify objects in view. In the future, you’ll be able to point your phone at a store. Using an AR view, Google can tell you ratings, descriptions, and pictures related to the store.
Join the conversation at our next Google Developer Group.
Interested in digging deeper into these technology announcements? What are consequences of connecting some of these ideas together? What opportunities do these capabilities give to our local developer community?
We’ll dig deeper into the latest announcements from Google I/O conference. We’ll discuss the various pathways for leveraging these technologies in your career. We’re excited to discuss how these tools can benefit local startups, makers and businesses in Orlando, FL.
When: May 24, 2018 – 6pm to 9pm
I/O Extended 2018 Orlando
Thursday, May 24, 2018, 6:00 PM
PowerDMS 101 S. Garland Ave #300 Orlando, FL
18 Members Went
• What we’ll do Google I/O is an annual software developer-focused conference which features a keynote on the latest updates and announcements by Google. The conference also hosts in-depth sessions focused on building web, mobile, and enterprise applications with Google and open web technologies such as Android, Chrome, Chrome OS, Google APIs, Goog…
Looking for a fun way to explore learning to code with your students or children? Consider exploring writing Minecraft mods using Python. In our house, we continue to enjoy building(destroying) together as a family in shared Minecraft worlds. I appreciate that Minecraft helps the kids exercise their thinking about working in 3D. The python language favoring concise expression, fast feedback and quick iteration will keep students engaged.
As a parent, I have been searching for ways to make learning math more attractive for one of my kids. In this particular case, he loves to read and often enjoys finding ways to avoid doing tasks related to math. I’m so thankful that he has developed a joy in reading. I don’t think I had that motivation at his age. During a trip to a bookstore, he expressed interest in the book “Learn to Program Minecraft” by Craig Richardson. As an experiment, we picked up the book to explore his engagement level. In one week, he got to chapter 4 and started requesting that we practice coding Minecraft together after school. I felt something like this.
Seymour Papert, a key influence in the learning theory of constructionism, aspired to create a math world where children would play with math as a learning tool. I believe that he would be proud of the various open source projects that connect Minecraft to computational thinking.
To help you get started with coding Minecraft mods with Python, I wanted to share a few tools to help you get started.
1. Raspberry Pi: The Raspberry Pi is a great $40 computer build to engage students in playing with physical computing and computer science. If you run the raspbian operating system on your Raspberry Pi, you already have a copy of Minecraft installed and related python tools.
2. Setup for Windows and Mac: If you run Minecraft(java edition) on a Windows or Mac OS, you will find the following tutorial from instructables helpful. The tutorial walks you through the process of setting up your Minecraft server, setting up the python api, and configuring your Minecraft environment.
3. Getting Started with Minecraft Pi: This resource from the Raspberry Pi foundation provides a concise set of steps to get started. Make sure to check out the link on playing with TNT. (The kids enjoy that one!)
4. MagPi Magazine issue on Minecraft coding: I’m a big supporter of the MagPi Magazine. I often give this magazine as a gift to my geek friends. They recently published an issue on Minecraft coding that you’d enjoy.
6. www.codecademy.com: This interactive tutorial provides a fun way to get started with python programming and many other languages. People learn best when you see a new idea and immediately apply it. Code academy was designed with this learning pattern in mind. You are coached to immediately apply every new programming concept in an online code editor.
As a parent, I want my children to feel prepared to support themselves and thrive in the economy of the future. Given I have relatively young kids, we have no idea what this future will look like. Here’s what we do know. Many of the jobs and opportunities of the future have not been invented yet. Due to technology advances, the fundamental work patterns of many industries continue to transform. With this undercurrent of change, we know that the workforce of the future will demand strong problem-solving skills, design thinking, and team collaboration. It’s easy to let kids become engaged with consuming technology. Kids naturally like to watch TV, engage with apps, and play games. How do we engage our kids to become makers and creative problem solvers? How do we give our kids the creative confidence to shape their future? How do we help them to care and have empathy? Our future, however, rests on our ability to engage students in a path and habit of learning that helps them become makers. Due to decreasing technology costs, it’s become affordable and fruitful to introduce kids to design thinking using code, digital fabrication, and physical computing.
Over the years of writing this blog, it’s been amazing to see the diffusion of the makerspace concept into culture. I will always cherish the opportunities I had to help start a makerspace in Macon, GA called SparkMacon. I’m very proud of our efforts to start a young makers program to engage families in making, tinkering, and engineering. I’ve talked to home schooling communities about their interest in applying maker education in their curriculum. I’ve enjoyed seeing makerspaces grow inside of schools and libraries. I encourage you to enjoy this TED talk by Phil and Liana at Toorak College who lead a school based makerspace. There’s still lots of work to be done. As I talk with makerspace operators on the south east of the United States, it can be challenging to sustain these efforts and keep engagement levels high.
Abstract: How do we develop a mindset that challenges students to embrace the thinking skills, digital technology and design approach associated with STEM? How do we also develop and equip our staff with the skills and knowledge aligned with STEM to best support our students? How do we inform parents about the role of STEM in learning? Taking up this challenge in 2015, Toorak College in Mt Eliza, Victoria designed a makerspace titled the DIGIZone (Design, Inspire, Gamify, Innovate) the epicenter of STEM where students from all ages of the school can tinker, make errors, design, problem find and solve, collaborate, create while accessing an array of traditional and digital tools.
As I continue to organize creative learning activities for my family and future meetups, I have felt the need to re-charge and re-frame my thinking. With that in mind, I wanted to connect you to key documents and ideas from an organization that I love, MakerEd.org. Many of their playbooks, blog posts, and tools helped us plan our efforts in growing a makerspace for Middle, GA, designing workshop experiences, and facilitating the community.
I have found that books like the “Art of Community” by Jono Bacon are also helpful for maker community efforts.
This free ebook provides ideas for motivation, project concepts, and teaching theory. The work has detailed plans for getting started and executing your maker club. The plan proposed encourages students to design and focus on a project concept. The book combines a project-based learning approach while encouraging the student to select a focus project. The plan proposes that students present their work at a conference like a local MakerFaire. You should be able to adapt this playbook to your local situation.
Thank you to the team at MakerEd.org for their important efforts to inspire educational makerspaces across the world!
What are your challenges in growing your makerspace community? What are your favorite stories of your maker community in action? Please share a comment below!
My wife and kids enjoy bird watching. In our dining room, we attached a bird feeder to a window in the room. My wife asked if I could hack together a way to snap pictures of birds that visit the bird feeder. After doing some good searches, I realized that SimpleCV has some easy capabilities enabling you to create a motion detection system with Python. SimpleCV has become one of my favorite open source computer vision tools that you program using python. In general, computer vision is the branch of computer science that deals with understanding images and video. In this post, I’ll try to outline the major ideas from this script by the folks from SimpleCV. I made a few edits to the script to save video frames with motion to disk. To learn more about getting started with python programming, check out this blog post.
In the world of computers, a computer image exists as a grid of numbers. Each number represents a color. A pixel is a cell in this grid of numbers at a particular (x,y) position. SimpleCV enables you to capture an image from your web camera using the following code.
1 2 3
from SimpleCV import *
cam = Camera()
current = cam.getImage()
Let’s say we capture two images taken within a 1/2 second of each other.
1 2 3 4
previous = cam.getImage() #grab a frame
time.sleep(0.5) #wait for half a second
current = cam.getImage() #grab another frame
diff = current - previous
SimpleCV defines an image subtraction operation so that you can find the differences between two images. If the current and previous images are exactly the same, SimpleCV will compute a black image. (i.e. a grid of zeros) If current and previous images have substantial differences, some of the cells in the diff image will have positive values.
At this point, we compute a ‘mean’ factor using all the pixel values from the diff image. If the mean value is higher than a particular threshold, we know that a motion event occurred. We capture an image and store the image to a file.
You can review the complete code solution below.
The following web page from SimpleCV outlines other applications of image math.
cam = Camera()
threshold = 5.0 # if mean exceeds this amount do something
i = 0
disp = SimpleCV.Display((1024, 768))
previous = cam.getImage() #grab a frame
time.sleep(0.5) #wait for half a second
current = cam.getImage() #grab another frame
diff = current - previous
matrix = diff.getNumpy()
mean = matrix.mean()
if mean >= threshold:
print "Motion Detected " + str(i)
# capture the image. Display it. Save the image as a JPEG.
img = cam.getImage()
img.save('%.06d.jpg' % i)
# change the filename counter variable.
i += 1
Interested in learning more about SimpleCV? Check out the following PyCon conference video
Abstract: Katherine Scott: This talk is a brief summary of Computer Vision tutorial we proposed for PyCon. In this talk we will discuss what computer vision is, why it’s useful, what tools exist in the Python ecosystem, and how to apply it to your project.