quarta-feira, julho 31, 2013

Tagged under: , , , , ,

How to Run minoru 3D webcam on Raspberry PI Board



Hello Friends, the purpouse of this simple post is show how to use a minoru 3d webcam on raspberry pi board.
This tutorial assume that you have a opencv installed on your board.
.





Minoru Web CAM

The script below  are a example of usage:

import cv2
import numpy as np

c = cv2.VideoCapture(0)
c.set(3,1280)
c.set(4,480)

while(1):
    _,visao = c.read()

    esquerdo = visao[0:480, 0:640]
    direito = visao[0:480, 640:1280]
    cv2.imshow('esquerdo',esquerdo)
    cv2.imshow('direito',direito)

    if cv2.waitKey(5)==27:
        break
    cv2.destroyAllWindows()

Explanation:


import cv2
import numpy as np


This first two lines are the libraries of functions that was used.


c = cv2.VideoCapture(0)
c.set(3,1280)
c.set(4,480)

Now we set the device that we going to use for capture image in the first line, note that the number in the argument field represent the device os /dev directory, for consult this run the folow command:


ls /dev/video*

and the response are one thing like this:


/dev/video0

The number showed, in this case '0', represent the number of device that can be used in this script. Returning to explanation, the others two lines are setting the widht and height parameters of the image captured, in particulary the minoru webcam only shows the two images with this resolution.


_,visao = c.read()

This command read the image, and attribute the result on "visao" var.


esquerdo = visao[0:480, 0:640]
direito = visao[0:480, 640:1280]

Now we split the image, generating two images, left (first line) and right(second line).


cv2.imshow('esquerdo',esquerdo)
cv2.imshow('direito',direito)

Finally the images are shown.

Captura_de_tela-MOV086.mp4-3

The next post we apply the concept of disparity to study the distance of objects.

Thanks,


[EOT]

2 comentários:

  1. Good demo, Which camera do you use? Will the latency improve if you don't send the video through streaming? I wonder if i can use it to position traking of a quadcopter.

    ResponderExcluir
    Respostas
    1. Thanks. The camera is a Minoru Webcam (http://ads.tt/HMOD). The latency has 3 causes: 1)Streaming throught the network; 2)The python code, used for split and treat the images and 3) Processament on raspberry pi ( but i don't have certain about this item). I believe that is possible do this work using this camera, or using other simple webcam. I was working with ar.drone and i used the camera onboard for search other robots in ground. If you need some help ask for me.

      Thanks.

      Excluir