2014年6月26日星期四

OpenCV4UDOO:UdooApp-EYE

OpenCV4UDOO(Android):UdooApp-EYE

This is a face recognition project based  Android

Project: https://code.google.com/p/opencv4udoo/
IMage 1 

OpenCV4UDOO:UdooApp-GPS


OpenCV4UDOO(Android):UdooApp-GPS
Project: https://code.google.com/p/opencv4udoo/



OpenCV4UDOO:UdooOpenCV Sample-Camera Preview


OpenCV4UDOO:UdooOpenCV Sample-Camera Preview
Project: https://code.google.com/p/opencv4udoo/

OpenCV4UDOO:UdooOpenCV Sample-Camera Control


OpenCV4UDOO(Android):UdooOpenCV Sample-Camera Control
Project: https://code.google.com/p/opencv4udoo/

OpenCV4UDOO:UdooOpenCV Sample - image-manipulations


OpenCV4UDOO(Android):UdooOpenCV Sample - image-manipulations
Project: https://code.google.com/p/opencv4udoo/


OpenCV4UDOO:UdooOpenCV Sample - color-blob-detection


OpenCV4UDOO(Android):UdooOpenCV Sample - color-blob-detection
Project: https://code.google.com/p/opencv4udoo/


OpenCV4UDOO:UdooOpenCV Sample - camera-calibration

OpenCV4UDOO(Android):UdooOpenCV Sample - camera-calibration

Project: https://code.google.com/p/opencv4udoo/

OpenCV4UDOO:UdooOpenCV Sample - 15 puzzle


OpenCV4UDOO(Android): UdooOpenCV Sample - 15 puzzle
Project: https://code.google.com/p/opencv4udoo/


OpenCV4UDOO:install



OpenCV4UDOO (Android ):install

You need download OpenCV_2.4.9_Manager_2.18_armv7a-neon.apk
and Install for UDOO 





done


2014年6月23日星期一

2014年6月17日星期二

OpenCV installation for UDOO(Ubuntu)

    OpenCV is released under a BSD license and hence it’s free for both academic and commercial use. It has C++, C, Python and Java interfaces and supports Windows, Linux, Mac OS, iOS and Android. OpenCV was designed for computational efficiency and with a strong focus on real-time applications. Written in optimized C/C++, the library can take advantage of multi-core processing. Enabled with OpenCL, it can take advantage of the hardware acceleration of the underlying heterogeneous compute platform. Adopted all around the world, OpenCV has more than 47 thousand people of user community and estimated number of downloads exceeding 7 million. Usage ranges from interactive art, to mines inspection, stitching maps on the web or through advanced robotics.
UDOO - Python-OPENCV TEST
To install OpenCV on the Ubuntu operating system.
sudo apt-get install python-dev python-numpy
sudo apt-get update
sudo apt-cache search opencv
sudo apt-get install libcv-dev libcv2.3 libcvaux-dev libcvaux2.3 libhighgui-dev libhighgui2.3 libopencv-calib3d-dev libopencv-calib3d2.3 libopencv-contrib-dev libopencv-contrib2.3 libopencv-core-dev libopencv-core2.3 libopencv-dev libopencv-features2d-dev libopencv-features2d2.3 libopencv-flann-dev libopencv-flann2.3 libopencv-highgui-dev libopencv-highgui2.3 libopencv-imgproc-dev libopencv-imgproc2.3 libopencv-legacy-dev libopencv-legacy2.3 libopencv-ml-dev libopencv-ml2.3 libopencv-objdetect-dev libopencv-objdetect2.3 libopencv-video-dev libopencv-video2.3 python-opencv

Test Python-OpenCV 
     python cvx2.py car.jpeg

cvx2.py code:
import sys
import cv2
import cv2.cv as cv
from cv2.cv import *
from cv2 import *

if __name__=='__main__':
   if len(sys.argv)>1:
      image=cv2.imread(sys.argv[1])
       
      cv2.imshow("UDOO-OPENCV",image )
 
      cv2.waitKey(0)

car.jpeg

2014年6月16日星期一

UDOO - Gesture Control Project

This is a UDOO vision control touch project, which is capable of gesture recognition under complex background. 


UDOO - Gesture Control Project Test Two

UDOO - Gesture Control Project Test One
        
With UDOO Video Capture function and its powerful computing capability,  we achieve real-time image capture and gesture recognition, here we use LED to display the I/O control. The following is a description of our design:

UDOO - Gesture Control Project
 The screen is divided in 9 hot point area. In each area, it will recognize the gesture as a  fist or a Palm to control the LED state.

     We use OpenCV under Android OS to do the image capture and gesture recognition, use Android ADK to pass the control signal to Android OS to control the Arduino I/O to implement the control platform.


Arduino CODE:
#include "variant.h"
#include "stdio.h"
#include "adk.h"

#define  LED_PIN1  10
#define  LED_PIN2  11
#define  LED_PIN3  12
#define  LED_PIN4  13

// Accessory descriptor. It's how Arduino identifies itself to Android.
char descriptionName[] = "ArduinoADK_2"; 
char modelName[] = "UDOO_ADK";           // your Arduino Accessory name (Need to be the same defined in the Android App)
char manufacturerName[] = "Aidilab";     // manufacturer (Need to be the same defined in the Android App)

// Make up anything you want for these
char versionNumber[] = "1.0";            // version (Need to be the same defined in the Android App)
char serialNumber[] = "1";
char url[] = "http://udoomv.blogspot.it/";      // If there isn't any compatible app installed, Android suggest to visit this url

USBHost Usb;
ADK adk(&Usb, manufacturerName, modelName, descriptionName, versionNumber, url, serialNumber);

#define RCVSIZE 128
uint8_t buf[RCVSIZE];
uint32_t bytesRead = 0;

void setup()
{
  Serial.begin(115200);   
  pinMode(LED_PIN1, OUTPUT);
  pinMode(LED_PIN2, OUTPUT);
  pinMode(LED_PIN3, OUTPUT);
  pinMode(LED_PIN4, OUTPUT);
  delay(500);
  Serial.println("UDOO ADK demo start...");
}

void loop()
{
  Usb.Task();

  if (adk.isReady()) {
    adk.read(&bytesRead, RCVSIZE, buf);// read data into buf variable
    if (bytesRead > 0) {
      if (parseCommand(buf[0]) == 1) {// compare received data
        // Received "1" - turn on LED
        digitalWrite(LED_PIN1, HIGH);
      } 
      else if (parseCommand(buf[0]) == 0) {
        // Received "0" - turn off LED
        digitalWrite(LED_PIN1, LOW); 
      }  

      if (parseCommand(buf[1]) == 1) {// compare received data
        // Received "1" - turn on LED
        digitalWrite(LED_PIN2, HIGH);
      } 
      else if (parseCommand(buf[1]) == 0) {
        // Received "0" - turn off LED
        digitalWrite(LED_PIN2, LOW); 
      }  

      if (parseCommand(buf[2]) == 1) {// compare received data
        // Received "1" - turn on LED
        digitalWrite(LED_PIN3, HIGH);
      } 
      else if (parseCommand(buf[2]) == 0) {
        // Received "0" - turn off LED
        digitalWrite(LED_PIN3, LOW); 
      }  

      if (parseCommand(buf[3]) == 1) {// compare received data
        // Received "1" - turn on LED
        digitalWrite(LED_PIN4, HIGH);
      } 
      else if (parseCommand(buf[3]) == 0) {
        // Received "0" - turn off LED
        digitalWrite(LED_PIN4, LOW); 
      }  
    }
  } 
}
// the characters sent to Arduino are interpreted as ASCII, we decrease 48 to return to ASCII range.
uint8_t parseCommand(uint8_t received) {
  return received - 48;
}

We need install Opencv for Android
http://opencv.org/platforms/android.html

And Use Eclipse


Java CODE:
 private AdkManager mAdkManagerX;

        mAdkManagerX = new AdkManager((UsbManager) getSystemService(Context.USB_SERVICE));
 registerReceiver(mAdkManagerX.getUsbReceiver(),mAdkManagerX.getDetachedFilter());

CODE:
 private CameraBridgeViewBase mOpenCvCameraView;

        mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.fd_activity_surface_view);
 mOpenCvCameraView.mCameraIndex = 0;
 mOpenCvCameraView.setCvCameraViewListener(this);

        public Mat onCameraFrame(CvCameraViewFrame inputFrame) 
        {
             ......
            Imgproc.blur(mGray, mGray, new Size(5,5));
            mNativeDetector.detect2(mGray, faces2); 
             ......
            mAdkManagerX.writeSerial("11AA"); 
             ...... 
         }

JNI C++ CODE:
#include "DetectionBasedTracker_jni.h"
#include "opencv2/core/core.hpp"
#include "opencv2/contrib/detection_based_tracker.hpp"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "stdio.h"
#include "string"
#include "vector"
#include "android/log.h"
#define LOG_TAG "FaceDetection/DetectionBasedTracker"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
using namespace std;
using namespace cv;
inline void vector_Rect_to_Mat(vector& v_rect, Mat& mat)
{
    mat = Mat(v_rect, true);
}
JNIEXPORT jlong JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject1
(JNIEnv * jenv, jclass, jstring jFileName, jint faceSize)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject enter");
    const char* jnamestr = jenv->GetStringUTFChars(jFileName, NULL);
    string stdFileName(jnamestr);
    jlong result = 0;
    try
    {
        DetectionBasedTracker::Parameters DetectorParams;
        if (faceSize > 0)
            DetectorParams.minObjectSize = faceSize;
        result = (jlong)new DetectionBasedTracker(stdFileName, DetectorParams);
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeCreateObject caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeCreateObject caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
        return 0;
    }

    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject exit");
    return result;
}

JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject1
(JNIEnv * jenv, jclass, jlong thiz)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject enter");
    try
    {
        if(thiz != 0)
        {
            ((DetectionBasedTracker*)thiz)->stop();
            delete (DetectionBasedTracker*)thiz;
        }
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeestroyObject caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeDestroyObject caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
    }
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject exit");
}

JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart1
(JNIEnv * jenv, jclass, jlong thiz)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart enter");
    try
    {
        ((DetectionBasedTracker*)thiz)->run();
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeStart caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeStart caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
    }
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart exit");
}

JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop1
(JNIEnv * jenv, jclass, jlong thiz)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop enter");
    try
    {
        ((DetectionBasedTracker*)thiz)->stop();
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeStop caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeStop caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
    }
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop exit");
}

JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize1
(JNIEnv * jenv, jclass, jlong thiz, jint faceSize)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize enter");
    try
    {
        if (faceSize > 0)
        {
            DetectionBasedTracker::Parameters DetectorParams = \
            ((DetectionBasedTracker*)thiz)->getParameters();
            DetectorParams.minObjectSize = faceSize;
            ((DetectionBasedTracker*)thiz)->setParameters(DetectorParams);
        }
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeStop caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeSetFaceSize caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
    }
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize exit");
}


JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect1
(JNIEnv * jenv, jclass, jlong thiz, jlong imageGray, jlong faces)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect enter");
    try
    {
        vector RectFaces;
        ((DetectionBasedTracker*)thiz)->process(*((Mat*)imageGray));
        ((DetectionBasedTracker*)thiz)->getObjects(RectFaces);
        vector_Rect_to_Mat(RectFaces, *((Mat*)faces));
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeCreateObject caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeDetect caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
    }
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect exit");
}

JNIEXPORT jlong JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject2
(JNIEnv * jenv, jclass, jstring jFileName, jint faceSize)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject enter");
    const char* jnamestr = jenv->GetStringUTFChars(jFileName, NULL);
    string stdFileName(jnamestr);
    jlong result = 0;

    try
    {
        DetectionBasedTracker::Parameters DetectorParams;
        if (faceSize > 0)
            DetectorParams.minObjectSize = faceSize;
        result = (jlong)new DetectionBasedTracker(stdFileName, DetectorParams);
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeCreateObject caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeCreateObject caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
        return 0;
    }

    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject exit");
    return result;
}

JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject2
(JNIEnv * jenv, jclass, jlong thiz)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject enter");
    try
    {
        if(thiz != 0)
        {
            ((DetectionBasedTracker*)thiz)->stop();
            delete (DetectionBasedTracker*)thiz;
        }
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeestroyObject caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeDestroyObject caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
    }
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject exit");
}

JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart2
(JNIEnv * jenv, jclass, jlong thiz)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart enter");
    try
    {
        ((DetectionBasedTracker*)thiz)->run();
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeStart caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeStart caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
    }
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart exit");
}

JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop2
(JNIEnv * jenv, jclass, jlong thiz)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop enter");
    try
    {
        ((DetectionBasedTracker*)thiz)->stop();
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeStop caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeStop caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
    }
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop exit");
}

JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize2
(JNIEnv * jenv, jclass, jlong thiz, jint faceSize)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize enter");
    try
    {
        if (faceSize > 0)
        {
            DetectionBasedTracker::Parameters DetectorParams = \
            ((DetectionBasedTracker*)thiz)->getParameters();
            DetectorParams.minObjectSize = faceSize;
            ((DetectionBasedTracker*)thiz)->setParameters(DetectorParams);
        }
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeStop caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeSetFaceSize caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
    }
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize exit");
}

JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect2
(JNIEnv * jenv, jclass, jlong thiz, jlong imageGray, jlong faces)
{
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect enter");
    try
    {
        vector RectFaces;
        ((DetectionBasedTracker*)thiz)->process(*((Mat*)imageGray));
        ((DetectionBasedTracker*)thiz)->getObjects(RectFaces);
        vector_Rect_to_Mat(RectFaces, *((Mat*)faces));
    }
    catch(cv::Exception& e)
    {
        LOGD("nativeCreateObject caught cv::Exception: %s", e.what());
        jclass je = jenv->FindClass("org/opencv/core/CvException");
        if(!je)
            je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, e.what());
    }
    catch (...)
    {
        LOGD("nativeDetect caught unknown exception");
        jclass je = jenv->FindClass("java/lang/Exception");
        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
    }
    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect exit");
}


The Same :
《Minority Report》Tom Cruise Gesture Controls

What's UDOO?

UDOO is a mini PC that could run either Android or Linux, with an Arduino-compatible board embedded.

 
UDOO is a powerful prototyping board for software development and design, it’s easy to use and with a few steps you can start using it and creating your projects with minimum knowledge.
 
                          
UDOO board
UDOO merges different computing worlds in one; each world has its strengths and weaknesses, and all of them are useful today in education as well as Do-It-Yourself (DIY) and rapid prototyping endeavours.
UDOO is an open hardware, low-cost computer equipped with an ARM i.MX6 Freescale processor for Android and Linux, alongside  Arduino DUE’s ARM SAM3X, both CPU integrated on the same board!
UDOO’s size is 4.33 inch x 3.35 inch (11 cm x 8.5 cm) and it has low power consumption.

 
The power of 4 Raspberry PI + Arduino DUE functionality = UDOO
UDOO goals:
  • Develop an innovative product for a growing market
  • Give a new vision to the educational framework: the idea is to train up a new generation of engineers, designers and software developers skilled in digital technology: physical computing, multi-media arts, interactive arts, IoT...
  • Boost up the DIY world
  • Offer a low cost embedded platform for interactive art with powerful tools: Processing, OpenCV, PureData, openFramework
  • Provide companies with a great tool for fast prototyping

UDOO – OPENCV – C++ CODE TEST

GStreamer - OpenCV Plugins   Feature:  C++ , High speed processing

OPENCV  Draw Text
sobel edge detection


We Need download : GStreamer - OpenCV Plugins 
http://gstreamer.freedesktop.org/modules/gst-plugins-bad.html


 examples :
static char text[20];
static CvFont font1;

memset(text,0,sizeof(text));
cvInitFont(&font1, CV_FONT_HERSHEY_SIMPLEX, 2.2, 2.2, 0, 6, 8);
static GstFlowReturn
gst_cv_smooth_transform (GstOpencvBaseTransform * base, GstBuffer * buf,
    IplImage * img, GstBuffer * outbuf, IplImage * outimg)
{
  GstCvSmooth *filter = GST_CV_SMOOTH (base);
  cvSmooth (img, outimg, filter->type, filter->param1, filter->param2,
      filter->param3, filter->param4);
  sprintf(text,"UDOO-OpenCV Test: %d",ivv);
  cvPutText(outimg, text, cvPoint(100, 100), &font1, CV_RGB(255,0,0)); 
  return GST_FLOW_OK;
}
run_it.sh:
  export PKG_CONFIG_PATH=/usr/lib/pkgconfig
./autogen.sh
./congigure
sudo make clean
make
sudo make install
sudo cp ./src/.libs/libgstopencv.so /usr/lib/gstreamer-0.10/libgstopencv.so
sudo cp ./src/.libs/libgstopencv.la /usr/lib/gstreamer-0.10/libgstopencv.la
gst-inspect-0.10 opencv
gst-launch-0.10 mfw_v4lsrc ! 'video/x-raw-yuv,width=640,height=480,framerate=90/1' ! ffmpegcolorspace ! cvsmooth ! ffmpegcolorspace ! ximagesink

Project: Machine Vision Project for UDOO

This is a machine vision control system, it can identify the color and size of objects in a production line, and then produce the judgment results according to the parameters, the results is defined by human like the category of size, category of color and so on. 

Structure

 1、 Controller: UDOO + Camera + Touchscreen+Ardunio +LED (MAIN)
 2、 Machinery: compressed-air + solenoid valve + conveyor belt (Optional)

UDOO - Python Camera example

 It is a Python code to control camera  


We need install  python-gst0.10  
run
  sudo apt-get install python-gst0.10
Next ,Coding for Pythonsave code file as name : udoo_camera.py
Next, Run It
 sudo python udoo_camera.py



udoo_camera.py CODE:
import sys, os
import pygtk, gtk, gobject
import pygst  
pygst.require("0.10")  
import gst  
import time

class GTK_Main:  
        def __init__(self):  
            window = gtk.Window(gtk.WINDOW_TOPLEVEL)  
            window.set_title("UDOO-Camera")  
            window.set_default_size(560, 480)  
            window.connect("destroy", gtk.main_quit, "WM destroy")  
            vbox = gtk.VBox()  
            window.add(vbox)  
            self.movie_window = gtk.DrawingArea()  
            vbox.add(self.movie_window)  
            hbox = gtk.HBox()  
            vbox.pack_start(hbox, False)  
            hbox.set_border_width(10)  
            hbox.pack_start(gtk.Label())  
            self.button = gtk.Button("snapshot")  
            self.button.connect("clicked", self.camera_snapshot)  
            hbox.pack_start(self.button, False)  
            self.button2 = gtk.Button("Quit")  
            self.button2.connect("clicked", self.exit)  
            hbox.pack_start(self.button2, False)  
            hbox.add(gtk.Label())  
            window.show_all()              
            self.player = gst.parse_launch ("mfw_v4lsrc ! mfw_v4lsink")
            bus = self.player.get_bus()
            bus.add_signal_watch()
            bus.enable_sync_message_emission()
            bus.connect("sync-message::element", self.on_sync_message)
            self.player.set_state(gst.STATE_PLAYING)       
        def camera_snapshot(self, w):             
             image= self.movie_window.window.get_image(0, 0, 560, 480)             
             print "Snapshot: "+str(time.time()) 
        def exit(self, widget, data=None):  
            gtk.main_quit()   
        def on_sync_message(self, bus, message):  
            if message.structure is None:  
                return  
            message_name = message.structure.get_name()  
            if message_name == "prepare-xwindow-id":  
                # Assign the viewport  
                imagesink = message.src  
                imagesink.set_property("force-aspect-ratio", True)  
                imagesink.set_xwindow_id(self.movie_window.window.xid)
 
GTK_Main()  
gtk.gdk.threads_init()  
gtk.main()