如何发送到Android到arduino char

时间:2016-04-05 19:29:14

标签: android arduino char tracking face

我想跟踪面对机器人 - 我在计算机上使用它 - 现在我想在ndroid。 arduino程序控制的摇摄和倾斜伺服系统。我必须发送给arduino只有一个例子" w"所以arduino让它+1移动伺服等。我不能发送给arduino那个char。

<div id=first style="border: 5px solid;">`
  <h1>Not much here to need to resize</h1>
</div>

<div id=second style="border: 5px solid;">
  <h1>There are a lot of words to word wrap and thus resize my box element much more</h1>
</div>

这是一个arduino代码

    public Mat onCameraFrame(CvCameraViewFrame inputFrame) {

    mRgba = inputFrame.rgba();
    mGray = inputFrame.gray();

    if (mAbsoluteFaceSize == 0) {
        int height = mGray.rows();
        if (Math.round(height * mRelativeFaceSize) > 0) {
            mAbsoluteFaceSize = Math.round(height * mRelativeFaceSize);
        }
        mNativeDetector.setMinFaceSize(mAbsoluteFaceSize);
    }

    MatOfRect faces = new MatOfRect();

    if (mDetectorType == JAVA_DETECTOR) {
        if (mJavaDetector != null)
            mJavaDetector.detectMultiScale(mGray, faces, 1.1, 2, 2, // TODO: objdetect.CV_HAAR_SCALE_IMAGE
                    new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size());
    }
    else if (mDetectorType == NATIVE_DETECTOR) {
        if (mNativeDetector != null)
            mNativeDetector.detect(mGray, faces);
    }
    else {
        Log.e(TAG, "Detection method is not selected!");
    }

    Rect[] facesArray = faces.toArray();

    for (int i = 0; i < facesArray.length; i++)
        Core.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3);
    for( int i=0; i<facesArray.length; i++ ) {
        rect( facesArray[i].x, facesArray[i].y, facesArray[i].width, facesArray[i].height ); 

    if(facesArray[i].x  < 640){
        arduinoPort.write("w");
    // println("left"); 
    //moutput.write("d");
        //mOutputStream.write("d".toString());  

   } 

    if(facesArray[i].x + facesArray[i].width > 1280){
        //println("right"); 
        arduinoPort.write("a");
       }

    if(facesArray[i].y + facesArray[i].height > 640){
        //println("bottom"); 
        arduinoPort.write("s");
       }

    if(facesArray[i].y < 320){
         //  println("top"); 
           arduinoPort.write("w");
          }

    if ((facesArray[i].x > 640) && (facesArray[i].x + facesArray[i].width < 1280)){
        //println("center"); 
           arduinoPort.write("z");

          }
    return mRgba;

0 个答案:

没有答案