#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
// Pointer Robot with Raspbery Pi and Arduino
// Copyright (C) 2018, ArduinoDeXXX All Rights Reserved.
//
// information:
// This is a sample code to open a preview window of openCV.
// Plug USB camera "Logitech C270" or its substitute into Raspberry Pi 3.
//
// This sample code is provided for an article to get Pointer robot.
// View the sites bellow to see more detail.
// https://www.instructables.com/id/Pointer-Robot-With-RPi-and-Arduino/
// https://www.instructables.com/id/Pointer-Robot-With-RPi-and-Arduino-JPN/
//
// acknowledge:
// http://my-web-site.iobb.net/~yuki/2017-09/raspberry-pi/capture/
'''

import cv2
print(cv2.__version__)
cap = cv2.VideoCapture(0)

while( cap.isOpened() ):
    ret, frame = cap.read()
    frame = cv2.resize(frame, (640, 480))    
    cv2.imshow('Capture',frame)
    key = cv2.waitKey(1)
    if key & 0x00FF  == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

