element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi Chef Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Pi Chef Design Challenge
  • More
  • Cancel
Pi Chef Design Challenge
Blog PiCA - Pi Chef Challenge Blog #4 : Testing OpenCV Installation and Building Block Set
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: giganggu
  • Date Created: 25 Feb 2018 7:16 PM Date Created
  • Views 394 views
  • Likes 6 likes
  • Comments 2 comments
  • raspberry
  • fridge
  • block set
  • opencv
Related
Recommended

PiCA - Pi Chef Challenge Blog #4 : Testing OpenCV Installation and Building Block Set

giganggu
giganggu
25 Feb 2018

Following the prior blog post about the installation of OpenCV to Raspberry Pi, then I  tested the installation using USB camera and Pi camera with python code. After that, I will show you the block set I build for putting a camera and raspberry in this post. This block set will put in the top of the fridge.

 

Test USB Camera

For this preliminary step, I will use webcam camera HD Logicool C270 with resolution 1280x720 pixel. Then I use the sample code for live view camera as below,

import numpy as np
import cv2
cap = cv2.VideoCapture(0)
if cap.isOpened() == False:
    print('Connecting camera')
else:
    print('Start Live View')
    cv2.namedWindow('USB Camera');
    cap.set(cv2.CAP_PROP_FRAME_WIDTH,640)
    cap.set(cv2.CAP_PROP_FRAME_HEIGHT,480)
    while( cap.isOpened() ):
        ret,frame = cap.read()
        if ret==False:
            print('Grabbing camera fail')
            break 
        cv2.imshow('Live',frame)       
        key = cv2.waitKey(5)
        if key==255: key=-1 
        if key >= 0:
            break
    print('Closing the camera') 
cap.release()
cv2.destroyAllWindows()

quit()

 

and this is the screenshot of the desktop

image

Fig.1 Screenshot of Live View using C270 Webcam camera

 

 

Test Pi Camera

After installing Pi camera provided in the Challenge Kit I copy the code from https://www.pyimagesearch.com/2015/03/30/accessing-the-raspberry-pi-camera-with-opencv-and-python/  as below,

from picamera.array import PiRGBArray
from picamera import PiCamera
import cv2
import time
camera = PiCamera()
camera.resolution = (640, 480)
camera.framerate = 32
rawCapture = PiRGBArray(camera, size=(640, 480))
time.sleep(0.1)
for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
     img = frame.array
     cv2.imshow("Live View", img)
     key = cv2.waitKey(1) & 0xFF
     rawCapture.truncate(0)
     if key == ord("q"):
          break

 

and the screenshot of the camera live view is shown below,

image

Fig.2 Screenshot of Live View using Pi Camera

 

 

Building Block set

The next step is building a block set for installed both webcam camera and raspberry. This block set will put in the top of the fridge for registering and recording the stock.

 

 

Closing Remarks

We have described our progress in this project. We have installed the openCV to Raspberry and test it using both USB camera and Pi Camera. We also build a block set for installing both camera and raspberry (Main server). The next step in our project plan is installed the Whatsapp messenger to raspberry for communication base. After that our plan is developing the blobing algorithm before recognition step. Hope that our project runs well.

  • Sign in to reply
  • giganggu
    giganggu over 7 years ago in reply to genebren

    Thank you Gene!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • genebren
    genebren over 7 years ago

    Nice progress on your project.  Keep up the good work.

    Gene

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube