Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 6796|回復: 14
打印 上一主題 下一主題

cmos 辨識 跪求 一問

[複製鏈接]
跳轉到指定樓層
1#
發表於 2010-3-18 21:22:55 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
我現在 已有辦法 讓影像在lcd上顯示  但今天 我想 鏡頭看到三角形物體 亮紅燈  看到正方形物體亮綠燈 我該怎做  我是用凌陽的 spce3200   請各位大師幫開一道路吧><
2#
發表於 2010-3-18 22:44:13 | 只看該作者
spce3200   ....
這應該是一塊主機板吧
所以你用攝影機抓了圖片顯示在LCD了?
想辨識三角形和四邊型?

這題目得看影像的樣子是如何
形狀有沒有重疊的可能
顏色是否一樣或是不同
大小會不會改變, 還是統一大小?
物體會不會擺正
作法都不一樣喔
3#
 樓主| 發表於 2010-3-19 14:49:32 | 只看該作者
回復 2# mzw2008

對他是一塊時習板 我買了他的COMS模組ov7720
我的想法很簡單 大小一致 顏色一致 只有 分方形 跟三角形 我都是用保麗龍做的
只要他她能判別哪個是方形 哪個是三角形 輸出訊號就可以了(到時候因該會給訊號到bs2控制機械手臂或只是簡單的亮燈) 這邊我實在不知如何做
我強在伺服機控制~~

拜託你們指點我哩^^   我想畢業><
4#
發表於 2010-3-19 15:30:22 | 只看該作者
請問大小一致是邊長的大小一致
還是面積的大小一致

邊長大小一致比較簡單的方法就是看面積的大小
反過來說面積大小一致最簡單的方法就是看邊長大小
5#
 樓主| 發表於 2010-3-19 16:01:02 | 只看該作者
簡單來說 EX我現在 有一個 2CM*2CM的方形  一個底2CM 高2CM 的三角形 這我要怎讓他去判別 有範例程式嗎 我找了好機天 都只有顏色辨識><
6#
發表於 2010-3-19 17:55:32 | 只看該作者
這個就看面積就能知道了
方型面積一定會比三角型大
7#
 樓主| 發表於 2010-3-19 19:27:44 | 只看該作者
那我該怎寫c 讓他去判斷面積 這方面我不會的說><
8#
發表於 2010-3-19 19:37:27 | 只看該作者
辯別是否 2CM*2CM的方形只要讀取矩形(要從中心點y軸水平左右移動測試)的四角是否相同的RGB圖素,
辯別是否一個底2CM 高2CM 的三角形則是頂點之列和底部之列去比較RGB圖素即可,
看你是使用什麼語言,
如果有用到directx sdk,就有更簡單的方式,
請參考人臉偵測的 c#範例程式
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using AForge.Imaging.Filters;
using AForge.Math;
using AForge.Imaging;
namespace i_rely_solely_on_god
{
    class Face_Detection
    {
        //Define variable for Convert RGB 2 YCBCR
        //double Y = 0;
        //double Cb = 0;
        double Cr = 0;
        int R = 0;
        int G = 0;
        int B = 0;
        int r = 0;
        int Testdetection, WPresentdetection = 0;
        int BPresentdetection1 = 0;
        AForge.Math.Histogram activeHistogram = null;
        //Main function for face detection
        public int[]  FaceDetection(Form1 Main, PictureBox PicFirst, PictureBox Picresult,TextBox TWskin,PictureBox face,TextBox TBskin)
        {
            Testdetection = 0;
            Graphics hh = PicFirst.CreateGraphics();
            Bitmap PreResult = new Bitmap(PicFirst.Image);
            Bitmap Result = new Bitmap(PicFirst.Width, Picresult.Height);
            Bitmap HisResult = new Bitmap(PicFirst.Width, Picresult.Height);
            Bitmap Template50 = new Bitmap("sample50.bmp");
            Bitmap Template25 = new Bitmap("sample25.bmp");
            Bitmap facee = new Bitmap(face.Width, face.Height);
            for (int i = 0; i < PicFirst.Width; i++)
            {
                for (int j = 0; j < PicFirst.Height; j++)
                {
                    //Getting red layer
                    R = PreResult.GetPixel(i, j).R;
                    //Getting green layer
                    G = PreResult.GetPixel(i, j).G;
                    //Getting blue layer
                    B = PreResult.GetPixel(i, j).B;
                    //Formula for convert RGB 2 YCBCR
                    //Y = 0.299 * R + 0.587 * G + 0.114 * B;
                    //Cb = -0.169*R - 0.332*G + 0.500*B;
                    Cr = 0.500 * R - 0.419 * G - 0.081 * B;
                    //Ckeck for "-" values(Because we can't use "-" values for RGB color)
                    if (Cr < 0)
                        //Convert to Positive values
                        Cr =0;
                    HisResult.SetPixel(i, j, Color.FromArgb((int)Cr, (int)Cr, (int)Cr));
                    if (Cr > 10)
                        //Convert to Positive values
                        Cr = 255;
                        //if (Cr>20)
                        //    //Convert to Positive values
                        //    Cr = Cr+128;
                        //Set the pixel  by cr value
                        Result.SetPixel(i, j, Color.FromArgb((int)Cr, (int)Cr, (int)Cr));
                    }
            }
         
            //Create filter form my image
            FiltersSequence processingFilter = new FiltersSequence();
            //Detection the adges
            processingFilter.Add(new Edges());
   
            WPresentdetection=0;
            BPresentdetection1= 0;
            //Apply filter for my pic
            Picresult.Image =processingFilter.Apply( Result);
            //Detect face with big template
            for (int d = 0; d <150-50; d+=20)
            {
                Testdetection = 0;
                WPresentdetection = 0;
                BPresentdetection1 = 0;
                for (int c = 0; c <150-50; c+=20)
                {
                    Testdetection = 0;
                    WPresentdetection = 0;
                    BPresentdetection1 = 0;
                    for (int w = 0; w < Template50.Width; w++)
                    {
                        for (int h = 0; h < Template50.Height; h++)
                        {
                            if (Template50.GetPixel(w, h).B == 255)
                            {
                                if (Result.GetPixel(d + w, c + h).B == Template50.GetPixel(w, h).B)
                                {
                                    WPresentdetection++;
                                }
                            }
                            //if (Template50.GetPixel(w, h).B == 255)
                            //{
                            //    if (Result.GetPixel(d + w, c + h).B == Template50.GetPixel(w, h).B)
                            //    {
                            //        BPresentdetection1++;
                            //    }
                            //}
                        }
                    }
                    TWskin.Text = WPresentdetection.ToString();
                    TBskin.Text = BPresentdetection1.ToString();
                    if (WPresentdetection > 377)//&&BPresentdetection1>1579)
                    {
                        hh.DrawRectangle(new Pen(Color.Red), d, c,60, 60);
                        for (int i = 0; i < 60; i++)
                        {
                            for (int j = 0; j< 60; j++)
                            {
                                r = PreResult.GetPixel(i + d, j + c).R;
                                facee.SetPixel(i, j, Color.FromArgb((int)r, (int)r, (int)r));
                                face.Image  = facee;
                            }
                        }
                        TWskin.Text = WPresentdetection.ToString();
                        TBskin.Text = BPresentdetection1.ToString();
                        WPresentdetection = 0;
                        BPresentdetection1 = 0;
                        Testdetection = 1;
                        break;
                    }
                    // Detect face with small template
                    //else
                    //{
                    //    Testdetection = 0;
                    //    WPresentdetection = 0;
                    //    for (int w = 0; w < Template25.Width; w++)
                    //    {
                    //        for (int h = 0; h < Template25.Height; h++)
                    //        {
                    //            if (Result.GetPixel(d + w, c + h).B == 255)
                    //            {
                    //                if (Result.GetPixel(d + w, c + h).B == Template25.GetPixel(w, h).B)
                    //                {
                    //                    WPresentdetection++;
                    //                }
                    //            }
                    //        }
                    //    }
                    //    if (WPresentdetection > 50)
                    //    {
                    //        hh.DrawRectangle(new Pen(Color.Red), d, c, 30, 30);
                    //        for (int i = 0; i < 30; i++)
                    //        {
                    //            for (int j = 0; j < 30; j++)
                    //            {
                    //                r = PreResult.GetPixel(i + d, j + c).R;
                    //                facee.SetPixel(i, j, Color.FromArgb((int)r, (int)r, (int)r));
                    //                face.Image = facee;
                    //            }
                    //        }
                    //        TWskin.Text = WPresentdetection.ToString();
                    //        WPresentdetection = 0;
                    //        Testdetection = 2;
                    //        break;
                    //    }
                    //}
                }
                if (Testdetection == 1 || Testdetection == 2)
                {
                    WPresentdetection = 0;
                    BPresentdetection1=0;
                    Testdetection = 0;
                    break;
                }
            }
            //Draw histogram
            AForge.Imaging.ImageStatistics stat =
            new AForge.Imaging.ImageStatistics(HisResult);
            if (stat != null)
            {
                //Do if the pic is gray
                if (stat.IsGrayscale)
                {
                    activeHistogram = stat.Red;
                }
                //Do if the pic is colourful
                if (!stat.IsGrayscale)
                {
9#
 樓主| 發表於 2010-3-19 19:52:22 | 只看該作者
OKOK 我去嘗試看看  各位大大有更好的意見 可以說出來喔^^
你們人真好~~~
10#
發表於 2010-3-19 20:02:49 | 只看該作者
被截掉一些
補足 :
   //Do if the pic is colourful
                if (!stat.IsGrayscale)
                {
                   activeHistogram = stat.Red;
                }
            }
            return (activeHistogram.Values);
        }
    }
}
11#
 樓主| 發表於 2010-3-21 15:14:35 | 只看該作者
我只要在我的程式上 補上人臉辨識 就可以了嗎 這幾天 在那研究 研究不太出來耶 可以給我註解嗎>< 感謝
12#
發表於 2010-3-23 16:54:19 | 只看該作者
下載了以下三個網頁裡的範例程式,這樣還畢不了業,那就-----,(你老師太扯了)
http://www.codeproject.com/KB/cs/Face_Detection_processing.aspx
-----------------------------------------------------------------------
http://www.codeproject.com/KB/au ... n_detection_wc.aspx
--------------------------------------------------
http://www.helloapps.com/AI/
13#
 樓主| 發表於 2010-3-26 16:33:26 | 只看該作者
哈哈 vegewell 謝辣  感謝你阿~~
14#
發表於 2011-6-8 22:03:56 | 只看該作者
請問SPCE3200 ADC 可以和視窗程式做搭配嗎?
15#
發表於 2011-6-8 23:45:47 | 只看該作者
以前看過ㄧ篇日文的論文提過,用面積跟週長比可以去判斷已知形狀。只要你要辨識的東西很固定,這種方法會很容易做而且辨識能力很強建。
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-4-29 07:34 , Processed in 0.208886 second(s), 7 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表