Showing posts with label up. Show all posts
Showing posts with label up. Show all posts

Monday, June 20, 2016

Getting your fridge to order food for you with a RPi camera and a hacked up Instacart API

This is a detailed post on how to get your fridge to autonomously order fruit for you when you are low.  An RPi takes a picture every day and detects if you have fruit or not using my Caffe web query code. If your fridge is low on fruit, it orders fruit using Instacart, which is then delivered to your house. You can find the code with a walk through here:
https://github.com/StevenHickson/AutonomousFridge

Some of my posts are things I end up using every day and some are proof of concepts that I think are interesting. This is one of the latter. When I was younger, I heard an urban legend that Bill Gates had a fridge that ordered food for him and delivered it same-day whenever he was low. That story always intrigued me and I finally decided to implement a proof of concept of it. Below is how I set about doing this.

Hacking up an Instacart API

The first thing we need is a service that picks out food and delivers it to you. There are many of these, but as I live in Atlanta, I chose Instacart. Now we need an API. Unfortunately, Instacart doesnt provide one, so we will need to make our own. 

Head over to instacart.com and set up an account and login. Then right click and view source. You are looking for a line in the source like this:
FirebaseUrl="https://instacart.firebaseio.com/carts/SOME_HASH_STRING_HERE

That string is what you need to access your instacart account. Open up a terminal and type:
curl https://instacart.firebaseio.com/carts/YOUR_HASH_STRING.json

You should get back a response that looks like this:
{"checkout_state":{"workflow_state":"shopping"},"items":{"1069829":{"created_at":1.409336316211E9,"qty":1,"user_id":YOUR_USER_ID}},"users":{"-JXAzAp6rgtM4u2dV2tI":{"id":YOUR_USER_ID"name":"StevenH"},"-Jj2_kFsu5hvZRhx4KX1":{"id":YOUR_USER_ID,"name":"Steven H"},"-Jp8VvDusSDOyEiJ0J5D":{"id":YOUR_USER_ID,"name":"Steven H"}}}

Now we just need to figure out what different items are. Pick a store and start adding items to your cart and run the same command. If I add some fruit (oranges, bananas, strawberries, pears) to my cart and then run the same curl request. I get something like this:
{"checkout_state":{"workflow_state":"shopping"},"items":{"1069829":{"created_at":1.409336316211E9,"qty":1,"user_id":YOUR_USER_ID},"8182033":{"created_at":1.431448385824E9,"qty":2,"user_id":YOUR_USER_ID},"8583398":{"created_at":1.431448413452E9,"qty":3,"user_id":YOUR_USER_ID},"8585519":{"created_at":1.431448355207E9,"qty":3,"user_id":YOUR_USER_ID},"8601780":{"created_at":1.424915467829E9,"qty":3,"user_id":YOUR_USER_ID},"8602830":{"created_at":1.43144840911E9,"qty":1,"user_id":YOUR_USER_ID}},"users":{"-JXAzAp6rgtM4u2dV2tI":{"id":22232545,"name":"StevenH"},"-Jj2_kFsu5hvZRhx4KX1":{"id":YOUR_USER_ID,"name":"Steven H"},"-Jp8VvDusSDOyEiJ0J5D":{"id":YOUR_USER_ID,"name":"Steven H"}}}

Now empty your cart and we will make sure we can add all those things to your cart with a curl request. Take your response from earlier, and use it in the following line:
curl -X PATCH -d YOUR_FULL_CART_RESPONSE https://instacart.firebaseio.com/carts/YOUR_HASH_STRING.json

Now, your cart should be full of fruit again. Now we just need a way to recognize whether your fridge has fruit or not.

Detecting fruit in your fridge

For this we just need a Raspberry Pi 2 Model B Project Board - 1GB RAM - 900 MHz Quad-Core CPU and a Raspberry PI 5MP Camera Board Module.
Set up your camera following these instructions and you will be ready to go. Set up your camera module in your fridge (or wherever you store your fruit).

We are going to use the Caffe framework for recognizing whether fruit is in the refrigerator drawer or not. You can read about how to do that here.
We are going to set this up similarly. Run the following commands to set things up:

git clone https://github.com/StevenHickson/AutonomousFridge.git
sudo apt-get install python python-pycurl python-lxml python-pip
sudo pip install grab sudo apt-get install apache2
mkdir -p /dev/shm/images
sudo ln -s /dev/shm/images /var/www/images

Then you must forward your router from port 5005 to port 80 on the Pi
Now you can edit test.sh with your info and run ./test.sh
Or add the following line to cron with crontab -e:
00 17 * * * /home/pi/AutonomousFridge/test.sh

This script takes a picture with raspistill and puts it in a symlinked directory in memory accessible from port 80. Then it sends that URL to the Caffe web demo and gets the result.
The Caffe demo shows how well it classifies the existence of fruit as shown below:



The end result of this is a script that runs every day at 5 pm. When your fridge doesnt have fruit, it adds a bunch of fruit to your Instacart cart. You can order it at your leisure to make sure you are home when it arrives. You could also use my PiAUISuite to get it to text you about your fruit status. It can be alot of fun to make a proof of concept of an old urban legend.

Consider donating to further my tinkering since I do all this and help people out for free.



Places you can find me
Read More..

Sunday, May 15, 2016

Setting up OMXPlayer GUI on the Raspberry Pi Updated

This is a nice little trick to get OMXPlayer to work nice and pretty within the file manager so that the keypresses work and you dont need to use the command line. 

I got my Raspberry Pi in the mail and started setting it up as a  media server with my projector, external HDDs, and sound system.

You can do this in Arch Arm or in Raspbian Wheezy (Its easier in Wheezy since in Arch you have to get LXDE and omxplayer installed).

First thing, I noticed that the resolution auto-selection script didnt work properly with my projector.
I went into /opt/vc/bin and ran:
tvservice -d /home/pi/projector
edidparser /home/pi/projector /home/pi/available

Most of the options you need to change are in /boot/config.txt

This will give you the available resolutions. Each one has a code associated with it and is either a CEA code (hdmi_group=1) or a DMT code (hdmi_group=2). Then you can set the code with the hdmi_mode=? (I like hdmi_mode=15 and hmdi_mode=5).
Sometimes audio doesnt work over HDMI. If it doesnt, set hdmi_drive=2

Overclocking the Raspberry Pi is really easy, you can definitely get up to 850 MHz by adding this into the /boot/config.txt file:
arm_freq=855
sdram_freq=500

I got up to 1 GHz easily with the following options:
over_voltage=6
arm_freq=1000
sdram_freq=500
core_freq=500

I made the mistake of installing vlc. Dont! The ARM processor cant really handle it (unless overclocked and then its still buggy).
Use omxplayer instead.

Unfortunately omxplayer is a command line tool and that can get bothersome. To easily get around this and use it, install xterm by running:

Note: You dont have to use xterm, you can use the built in lxterminal instead by replacing xterm with lxterminal in all the examples below. However, xterm allows for the nice fullscreen option that omxplayer messes up.

sudo apt-get install xterm

Then right click one of your avi files and select open with, then click custom command line tool, type in:
xterm -fullscreen -fg black -bg black -e omxplayer -o hdmi -r %f

and check the box saying always do this so you only have to double click on any avi file in the future and it will do the same thing.


This opens up omxplayer in a new terminal so the key presses, such as p (pause) and q (quit), work. It also opens it up in fullscreen (the -r flag and the -fullscreen flag for xterm). Note: The rest of the display goes to sleep after a while so if the screen is black when the movie quits, shake the mouse or press a key to wake it up.

Omxplayer Problems

For detail on issues and how to fix them, see here:
Updating Raspberry Pi packages, kernel, and firmware (also fixing omxplayer)

If you are having problems with the video not working or not showing or the screen locking, make sure your raspberry pi is up to date by running:
sudo apt-get update && sudo apt-get upgrade

**HELP my mouse and keyboard dont work  (SOLUTION)**
If it still doesnt work, you may need to upgrade your firmware (which is generally a good idea anyways) using:
sudo apt-get -y dist-upgrade
and also 
sudo rpi-update
The guide for updating your firmware can be found here:
https://github.com/Hexxeh/rpi-update

Also make sure your gpu_mem split is at a reasonable level such as 128/128 by adding the line
gpu_mem=128
in the /boot/config.txt file in the newer firmware versions

To be able to easily find and intelligently play videos automatically, see this page:
http://stevenhickson.blogspot.com/2013/03/playing-videos-intelligently-with.html

Omxplayer Key Bindings:

  • 1 Increase Speed
  • 2 Decrease Speed
  • j Previous Audio stream
  • k Next Audio stream
  • i Previous Chapter
  • o Next Chapter
  • n Previous Subtitle stream
  • m Next Subtitle stream
  • s Toggle subtitles
  • q Exit
  • Space or p Pause/Resume
  • - Decrease Volume
  • + Increase Volume
  • Left Seek -30
  • Right Seek +30
  • Down Seek -600
  • Up Seek +600

Check out my other Raspberry Pi Fixes/How tos:
http://stevenhickson.blogspot.com/2012/10/using-raspberry-pi-as-web-server-media.html
http://stevenhickson.blogspot.com/2012/10/fixing-raspberry-pi-crashes.html

Consider donating to further my tinkering.


Places you can find me
Read More..

Tuesday, May 10, 2016

Computer Hangs at Start up

Q. My Computer Hangs for about 2 to 3 minutes at Start-up. I cannot access the Start button. What can i do?

A. The problem may be due to a service "Background Intelligent Transfer" running at background.
In order to solve this problem, perform the following steps:
  • Click on Start >> Run.
  • Type "msconfig" without quotes then click on OK
  • Now, Go to Services tab, Disable Background Intelligent Transfer Service, apply the changes
  • Reboot your system.
Thats all...
Read More..

Sunday, May 1, 2016

Computer Science Teaching Fellows Starting Up in Charleston SC



Google recently started up an exciting new program to ignite interest in computer science (CS) for K12 kids. Located in our South Carolina data center, the Computer Science Teaching Fellows is a two-year post graduate fellowship for new STEM teachers and CS graduates. The goal is to bring computer science and computational thinking to all children, especially underrepresented minorities and girls, and close the gap between the ever-increasing demand in CS and the inadequate supply. We hope to learn what really works and scale those best practices regionally and then nationally.

The supply of CS majors in the pipeline has been a concern for many years. In 2007, the Computer Science education community was alarmed by the lack of CS majors and enrollments in US colleges and universities.

Source: 2009-2010 CRA Taulbee Survey (http://www.cra.org/resources/)

This prompted the development of several programs and activities to start raising awareness about the demand and opportunities for computer scientists, and to spark the interest of K12 students in CS. For example, the NSF funded curriculum and professional development around the new CS Principles Advanced Placement course. The CSTA published standards for K12 CS and a report on the limited extent to which schools, districts and states provide CS instruction to their students. CS advocacy groups, Computing in the Core and Code.org have played an instrumental role in adding provisions to the reauthorization of the Elementary and Secondary School Act to support CS education. More generally, we have seen innovations in online learning with MOOCs, machine learning to provide personalized learning experiences, and platforms like Khan Academy that allow flipped classrooms.

All of these activities represent a convergence in the CS education space, where existing programs are ready for scale, and technological advancements can support that scale in innovative ways. Our Teaching Fellows will be testing after school programs, classroom curriculum and online CS programs to determine what works and why. They’ll start in the local Charleston area and then spread the best programs and curriculum to South Carolina, Georgia, North Carolina (where we also have large data centers). They are currently preparing programs for the fall semester.

We are very excited about the convergence we are seeing in CS education and the potential to bring many more kids into a field that offers not only great career opportunities but also a shot at really making a difference in the world. We’ll keep you posted on the progress of our Teaching Fellows.


Read More..

Wednesday, March 23, 2016

Beam me up

We all are familiar with the teleportation transporters used in Sci-Fi shows like Star Trek. In fact were so familiar with the technology that we can almost be forgiven for believing that one day this will exist. Researchers at the University of Maryland are working on teleportation, but theres a twist; they dont beam atoms across space, but the information held by atoms. Read  or listen to: "Beam Me Up? Teleporting Is Real, Even If Trekkie Transport Isnt" to find out more.


from The Universal Machine http://universal-machine.blogspot.com/

IFTTT

Put the internet to work for you.

Delete or edit this Recipe

Read More..

Friday, February 5, 2016

Opening up Course Builder data



Course Builder is an experimental, open source platform for delivering massive online open courses. When you run Course Builder, you own everything from the production instance to the student data that builds up while your course is running.

Part of being open is making it easy for you to access and work with your data. Earlier this year we shipped a tool called ETL (short for extract-transform-load) that you can use to pull your data out of Course Builder, run arbitrary computations on it, and load it back. We wrote a post that goes into detail on how you can use ETL to get copies of your data in an open, easy-to-read format, as well as write custom jobs for processing that data offline.

Now we’ve taken the next step and added richer data processing tools to ETL. With them, you can build data processing pipelines that analyze large datasets with MapReduce. Inside Google we’ve used these tools to learn from the courses we’ve run. We provide example pipelines ranging from the simple to the complex, along with formatters to convert your data into open formats (CSV, JSON, plain text, and XML) that play nice with third-party data analysis tools.

We hope that adding robust data processing features to Course Builder will not only provide direct utility to organizations that need to process data to meet their internal business goals, but also make it easier for educators and researchers to gauge the efficacy of the massive online open courses run on the Course Builder platform.
Read More..
 
Copyright 2009 Information Blog
Powered By Blogger