Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > Android อยากทราบว่า ต้องใช้ Code if-else แบบใด จึงจะแปลงภาพผลไม้จากการถ่ายรูป แล้วบอกได้ว่าเป็นผลไม้ชนิดอะไร ด้วยข้อมูลรูปผลไม้ที่เตรียมไว้ครับ



 

Android อยากทราบว่า ต้องใช้ Code if-else แบบใด จึงจะแปลงภาพผลไม้จากการถ่ายรูป แล้วบอกได้ว่าเป็นผลไม้ชนิดอะไร ด้วยข้อมูลรูปผลไม้ที่เตรียมไว้ครับ

 



Topic : 125165



โพสกระทู้ ( 131 )
บทความ ( 12 )



สถานะออฟไลน์




อยากทราบว่า ต้องใช้ Code if-else แบบใด จึงจะแปลงภาพผลไม้จากการถ่ายรูป แล้วบอกได้ว่าเป็นผลไม้ชนิดอะไร ด้วยข้อมูลรูปผลไม้ที่เตรียมไว้ ซึ่งมีข้อมูลดังนี้

1. Code MainActivity.java ครับ

Code (Android-Java)
import android.os.Bundle;
import android.provider.MediaStore;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends Activity {

    ImageView imgView;
    static final int REQUEST_IMAGE_CAPTURE = 1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //*** ImageView
        imgView = (ImageView) findViewById(R.id.imgView);

        //*** Take Photo
        final Button btnTakePhoto = (Button) findViewById(R.id.btnTakePhoto);
        // Perform action on click
        btnTakePhoto.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
                    startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
                }
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        //Start of Decision Tree
        if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
            Intent newActivity = new Intent(MainActivity.this,ActivityForm2.class);
            startActivity(newActivity);
        }
        else
        {
            Intent newActivity = new Intent(MainActivity.this,ActivityForm3.class);
            startActivity(newActivity);
        }
        //End of Decision Tree
    }

}


โดยจุดสำคัญอยู่ที่ Code แถว //Start of Decision Tree ถึง //End of Decision Tree อยากได้วิธี if-else ที่สามารถแปลงภาพผลไม้จากการถ่ายรูป แล้วบอกได้ว่าเป็นผลไม้ชนิดอะไร ด้วยข้อมูลรูปผลไม้ที่เตรียมไว้ครับ

2. Code ActivityForm2.java ครับ

Code (Android-Java)
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

/**
 * Created by sumate on 10/30/2016 AD.
 */
public class ActivityForm2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
    }

}


หมายเหตุ : ถ้าถ่ายรูปผลไม้ Apple แล้วตรงกับรูปภาพ Apple ที่ train ไว้ ก็จะแสดง Activity ว่า "เป็นผลไม้ แบบ Apple"

3. Code ActivityForm3.java ครับ

Code (Android-Java)
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

/**
 * Created by sumate on 10/30/2016 AD.
 */
public class ActivityForm3 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
    }

}


หมายเหตุ : ถ้าถ่ายรูปผลไม้อื่นๆ แล้วตรงกับรูปภาพผลไม้อื่นๆ ที่ train ไว้ ก็จะแสดง Activity ว่า "เป็นผลไม้ แบบอื่นๆ"

4. Code activity_main.xml ครับ

Code (XML)
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="  บอกประเภทผลไม้ ด้วยกล้อง"
            android:layout_span="1"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </TableRow>

    <View
        android:layout_height="1dip"
        android:background="#CCCCCC" />

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:orientation="horizontal" >


        <ImageView
            android:id="@+id/imgView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.75"
            android:src="@mipmap/orange" />

        <Button
            android:id="@+id/btnTakePhoto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="ส่องผลไม้" />
    </TableLayout>

    <View
        android:layout_height="1dip"
        android:background="#CCCCCC" />

</TableLayout>


5. Code activity_main2.xml ครับ

Code (XML)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:text="เป็นผลไม้ แบบ Apple"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:id="@+id/textView"
        android:textSize="20sp"
        android:textColor="@android:color/black" />

</RelativeLayout>


6. Code activity_main3.xml ครับ

Code (XML)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:text="เป็นผลไม้ แบบอื่นๆ"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:id="@+id/textView"
        android:textSize="20sp"
        android:textColor="@android:color/black" />

</RelativeLayout>


7. Diagram ความต้องการของ App ครับ

diagram

8. รูปตัวอย่างในการทำ train data เพื่อแยกประเภทผลไม้ ระหว่าง Apple กับอื่นๆ ครับ

https://drive.google.com/open?id=0B6nvQpUoHWoeeXl1XzVHaFpZM0k



Tag : Mobile, Android, JAVA, Windows, Linux, Mac







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-10-30 21:10:28 By : doanga2007 View : 1176 Reply : 2
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

เก็บลงใน Table ดีกว่าน่ะครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-10-31 12:06:00 By : mr.win
 


 

No. 2

Guest


ขอบคุณครับ สำหรับข้อมูล ตอนนี้ผมได้คำตอบแล้ว ซึ่งใช้วิธี OpenCV color blob detection for Android ครับ

Source : https://github.com/doanga2007/FruitSearch

คู่มือการสอน : https://docs.google.com/presentation/d/1s0KvqZm0kmPYRdjQNgKFPan0RjNWBCjkem23UkXh2GE/edit#slide=id.g2e200109_1_0
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-30 20:51:21 By : doanga1
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : Android อยากทราบว่า ต้องใช้ Code if-else แบบใด จึงจะแปลงภาพผลไม้จากการถ่ายรูป แล้วบอกได้ว่าเป็นผลไม้ชนิดอะไร ด้วยข้อมูลรูปผลไม้ที่เตรียมไว้ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่