Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - sodanum

#17
ตอนผมทดลองครั้งแรกจับ R มาใส่ มั่วๆ บางครั้ง พอจับที่ตัวถังเหล็กที่ครอบอยู่ อุณหภมิ
มันจะอ่านได้ -120 องศา พอดีผม ไม่มี R 4.7 โอม มีแต่มากกว่า กับ น้อยกว่า เลยใส่ทดลองไปก่อน

แต่ถ้าเทียบกับเครื่องสำเร็จรูป อุณหภูมิ ของผม มันจะสูงกว่า ประมาณเกือบ 1 องศา เลยสงสัย
ว่า R ที่ใส่มันจะมีผล ซะอีก ขอบคุณครับสำหรับข้อมูลครับ .....  ;D

ว่าแต่ ไม่รู้ว่า arduino หรือ  เครื่องสำเร็จ อันไหนแม่นกว่ากัน... เหอะๆๆ

#18


จากรูป เจ้า DS18B20 เราต้องต่อ ตัวต้านทาน 4.7 k โอม
ถ้าตัวต้านทาน ที่เอามาต่อ มีค่ามากกว่า หรือน้อย กว่า 4.7k โอม
จะมีผลต่ออุณหภมิที่ DS18B20 วัดได้หรือเปล่าครับ

:)

ขอบคุณครับ
#19
ผมได้ชมคลิป ตัวนี้ครับ

การใช้พัดลมให้ได้เหมือนแอร์
http://www.youtube.com/watch?v=5dsa_tfjR5I

เลยเอามาทดลองใช้งานในห้องดูซะเลย งานนี้ ใช้ Arduino + DS18B20  + C#
















จากการทดลอง ประมาณ 20 นาที (1200 วินาที)




8)

อุณหภูมิลดลงประมาณเกือบๆ 1 องศา ช่วงทดลองประมาณ บ่าย 3 - 4 โมง
ดูเหมือนลดลงไม่มาก แต่ที่จับจากความรู้สึกของตัวเอง รู้สึกมันเย็นสบายขึ้น พอสมควรครับ
อาจจะเป็นเพราะอากาศมีการถ่ายเทมากขึ้น เราเลยหายใจได้สะดวกขึ้น
โดยเฉพาะตรงใกล้ๆ หน้าต่าง จะรู้สึกเลยว่ามีลมเย็นเข้ามา...

การทดลองนี้ยังไม่สมบูรณ์เท่าไร จริงๆ ควรต้องมี DS18B20 อีกตัวหนึ่งไว้วัดอุณหภมิ
ภายนอกห้องด้วย พอดีผมมีแค่ตัวเดี่ยว  เอาไว้รอซื้อมาอีกตัวจะมา Update ให้นะครับ

:-*

สำหรับ Arduino ผมใช้ lib ที่ชื่อว่า DallasTemperature  โปรแกรมเลยออกมาสั้นนิดเดียว
(ใช้ lib ก็ดีครับ ง่ายดี แต่ทำให้เราโง่ลงนี้สิ เหอะๆๆ)

Arduino Code

#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup(void)
{
  Serial.begin(9600);
  sensors.begin();
}

void loop(void)
{
  sensors.requestTemperatures();
  Serial.println(sensors.getTempCByIndex(0));   
}




C# Code


    public partial class Form1 : Form
    {

        string RxString;
        uint rxCounter;

        public Form1()
        {
            InitializeComponent();
        }

        private void buttonStart_Click(object sender, EventArgs e)
        {
            serialPort1.PortName = "COM3";
            serialPort1.BaudRate = 9600;
            try { serialPort1.Open(); }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
            if (serialPort1.IsOpen)
            {
                buttonStart.Enabled = false;
                buttonStop.Enabled = true;
                textBox1.ReadOnly = false;
            }

        }

        private void buttonStop_Click(object sender, EventArgs e)
        {
            try
            {
                if (serialPort1.IsOpen)
                {
                    serialPort1.Close();
                    buttonStart.Enabled = true;
                    buttonStop.Enabled = false;
                    textBox1.ReadOnly = true;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }

        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (serialPort1.IsOpen) serialPort1.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
       
        private void DisplayText(object sender, EventArgs e)
        {
            textBox1.Text = RxString;
            chart1.ChartAreas[0].AxisY.Minimum = 25;
            chart1.ChartAreas[0].AxisY.Maximum = 37;
            chart1.ChartAreas[0].AxisY.Interval = 1;

            chart1.ChartAreas[0].AxisX.Interval = 60;
            chart1.ChartAreas[0].AxisX.Minimum = 0;
            chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
                       
            chart1.ChartAreas[0].AxisY.Title = "C";
            chart1.ChartAreas[0].AxisX.Title = "Time";
           

            chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.Gray;
            chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.Gray;
            chart1.Series[0].Color = Color.Red;
            chart1.Series[0].Points.AddXY(rxCounter, RxString);
        }
        private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            try
            {
                RxString = serialPort1.ReadLine();
                this.Invoke(new EventHandler(DisplayText));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
    }







#20
ผม Up Program กับ Code ให้แล้วนะครับ ลองเอาไปทดสอบดูครับ  :-*
#21
ออกงานภาคสนามมาครับ ตอนนี้ได้รับบาดเจ็บต้องกลับมาเลียแผล  ;D
#22
ช่วงนี้กำลังบ้า C# เลยใช้แต่  Visual Studio พอจับ เจ้า Arduino มาเล่น เลยสงสัยว่า
เราสามารถเขียน โปรแกรม Arduino บน VS ได้หรือเปล่า

ถามอากู๋ ไปเจอกับ  http://www.visualmicro.com/  เลยเก็บมาเล่าให้ฟังครับ

ใครสนใจก็เตรียมเครื่องมือได้เลย

โปรแกรม ที่ต้องใช้

- Arduino 1.0.5  : http://arduino.cc/en/Main/Software   คงมีกันอยู่แล้ว
- Visual Micro (1309.11) : http://visualmicro.codeplex.com/releases/view/105966
- Visual Studio 2012  ( Express  ใช้ไม่ได้นะครับ ต้องเป็น Professional หรือ Ultimate)

วิธีใช้งานเบื้องต้น ดูใน Vdo ละกันครับ..


http://www.youtube.com/v/i-IrsXlPX80


จับ Arduino กับ C# มาอยู่ใน Projects เดี่ยวกัน

http://www.youtube.com/v/95o207zl3Po


สะดวกในการเขียน โปรแกรม Arduino ดีครับ เพราะมันมีตัวช่วยในการเขียนโปรแกรม
พิมพ์คำสั่งแค่บางส่วนมัน show ขึ้นมาเลยว่าเป็นคำสั่งไหน พอ กด tap ก็ลงคำสั่งให้เลย
เหมาะสำหรับคนขึ้ลืมแบบผม จำคำสั่งไม่ค่อยได้  ;D




#23
** Hand of God V1.31 update 29/11/2556 ***

C# + Emgu Cv Libery ตัวเทพสำหรับ คอ  Image processing

หลักการก็คือ ใช้  webcam ตรวจจับมือขวา ว่าเคลื่อนไปทางซ้ายหรือขวา
เข้าหา webcam หรือ ออกจาก webcam
แล้วก็จำลองการกด keyboard เพื่อไปควบคุมโปรแกรมเล่นเพลง ดูหนัง


http://www.youtube.com/v/R7G5zyMoHMo


download ตัวเก่า

Program ตัวเก่า >> http://upload.ohozaa.com/download/10384/Hand-Of-Godrar
C# Code     >>  http://upload.ohozaa.com/download/10382/Hand-Of-God-Coderar

download Hand of God V1.31 ** update 29/11/2556

Download V1.31>> http://www.mediafire.com/download/0ab4i5q3s2jr49c/Hand+Of+God++V1.31.rar




Hand of god V1.31 ตัวนี้พัฒนาขึ้นมาอีกหลายอย่างครับ

มีอะไรใหม่บ้าง

- แก้ปัญหา Bug เปลี่ยนรูปไม่ได้ ของ V1.30

- ติดตั้งถอดโปรแกรมได้ง่ายๆ (เพิ่งทำเป็น)

- เปลี่ยนวิธีตรวจสอบการเคลื่อนที่ใหม่ ทำให้ตรวจจับง่ายกว่าเดิม

- ตั้งค่า Min Size ของ รูปต้นแบบได้ เครื่องไม่แรง ภาพจะไม่กระตุกครับ
ผมลองกับ cpu celeron note book ก็ใช้ได้

- เพิ่มการควบคุมแบบใหม่
# เอามือค้างไว้กับที่
# ขึ้นบน หรือ ลงล่าง แล้วค้างไว้
# ซ้ายไปขวา หรือ ขวาไปซ้าย แล้วค้างไว้

ตัวอย่างเช่น เรา Setup ให้ เคลื่อนมือจาก บนลงล่าง เป็นการลดเสียงเพลง 10%
ถ้าเราต้องการลด 50% ก็ต้อง เคลื่อนมือ 5 รอบ อาจปวดแขนได้

สำหรับ V1.31 เราก็แค่เคลื่อนมือจากบนลงล่างแล้วค้างไว้ จนเสียงเหลือตามที่ต้องการ
แล้วค่อยเอามือออกจากหน้ากล้องได้เลย

รูปแบบการตรวจจับของมือ V1.31



วิธีใช้งานเบื้องต้นครับ (program จะไม่เหมือนกับใน คลิปนะครับ ในคลิปเป็นตัวทดสอบ)

















ทดสอบ






ตัวอย่าง keyboard



#24
Projects / Color Detection with Emgu Cv Library
September 07, 2013, 03:41:21 PM
ช่วงนี้กำลัง หัดเล่น c# อยู่ครับ กะว่าจะเอามาทำอะไรเล่นสนุกๆ กับ Arduino  8)

หลังจากเจ้าพ่อเข้าร่างแล้ว จึงเกิดนิมิต โปรเจค เด็กน้อย ขึ้นในหัว แต่ปัญญามันไม่ตามไป
เลยต้องค่อยๆ ศึกษาหาความรู้ไปที่ละส่วน จะใช้ Processing* เมียหลวง  เขียนขึ้นมา
ก็ไม่เร้าใจซะแล้ว แบบนี้ต้องหนีไปลงอ่าง เอ่ย...  ต้องลอง อะไรใหม่ๆ ให้ชีวิตมีสีสัน กันบาง
ทิ้งเมียเก่า Processing * มาหาอีหนู c#  เด็กใหม่มันสู้มือ  กว่าจะพอรู้เรื่อง อากู๋ บ่น อุบ...

c# ของเขาดีจริง ข้อมูล มากมาย หาความรู้ได้ไม่ยาก เจอ Emgu Cv Library* ที่กลายพันธุ์
มาจาก Open Cv* ให้ชาว c# ได้เล่นแบบง่ายๆ  ยิ่งถูกใจใหญ่
Image processing บนเรียนหนึ่งระหว่างทาง ก่อน ไปถึงโปรเจค เด็กน้อย ที่ตั้งใจไว้

ฮัลเลวังกา แขกขอลาไปกินไอติม...
Color Detection with Emgu Cv Library

http://www.youtube.com/v/c4Dfvn6VQMo


สำหรับความรู้ที่ได้จากบทเรียนแรกนี้ก็คือ ความเข้าใจเรื่องเกี่ยวกับ ระบบสี HSV หรือ HSB

H =  Hue  สีต่างๆ ที่ตาเรามองเห็น ซึ่งถูกแทนด้วยองศา  0 ถึง 360 องศา  สำหรับ Emgu CV จะมีค่าอยู่ที่ 0-180

S = Saturation   ความสดของสี  0 ถึง 100   สดน้อย ถึง สดมาก Emgu Cv มีค่าอยู่ที่ 0-255

B,V =  Brightness คือ ระดับความสว่างและความมืดของสี  0 ถึง 100   ค่า Brightness มาก สีนั้นสว่างมาก  Emgu Cv มีค่าตั้งแต่ 0-255

;D

Download Program>> http://www.mediafire.com/download/ltop3f37v536ifo/Color.rar
Source code >> http://www.mediafire.com/download/oei3ip0xmdeo7jx/Color_detection.rar

ใครสนใจลองเอา Code ไปแกะดูครับ มือใหม่หัดเขียน C# มั่วหน่อยนะครับ.. :-[

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.Util;

namespace Color_detection
{
    public partial class Form1 : Form
    {
        #region Globle Var

        private Capture capture;
        private bool captureInProgress;
        private bool imageInProgress;
        String filenameload;
        Image<Bgr, Byte> ImageFrame = new Image<Bgr, Byte>(320, 240);
        Image<Bgr, Byte> ImageHSVwheel = new Image<Bgr, Byte>("HSV-Wheel.png");
        Image<Hsv, Byte> hsvImage = new Image<Hsv, Byte>(0, 0);
        int diff_LH;

        #endregion

        public Form1()
        {
            InitializeComponent();
            imageBox3.Image = ImageHSVwheel;
            Application.Idle += ProcessFrame;
        }

        #region Main Program

        private void ProcessFrame(object sender, EventArgs e)
        {
            if (captureInProgress)
            {
                ImageFrame = capture.QueryFrame();
                ImageFrame = ImageFrame.Resize(imageBox1.Width, imageBox1.Height, Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR);
                imageBox1.Image = ImageFrame;
                ImageProcessing();
            }

            if (imageInProgress)
            {
                ImageFrame = new Image<Bgr, byte>(filenameload);
                int[] whD = scaleImage(ImageFrame.Width, ImageFrame.Height);
                ImageFrame = ImageFrame.Resize(whD[0], whD[1], Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR);
                imageBox1.Image = ImageFrame;
                ImageProcessing();
            }


        }
        private void ImageProcessing()
        {
            Image<Gray, Byte> ImageFrameDetection = cvAndHsvImage(
                ImageFrame,
               Convert.ToInt32(numeric_HL.Value), Convert.ToInt32(numeric_HH.Value),
               Convert.ToInt32(numeric_SL.Value), Convert.ToInt32(numeric_SH.Value),
               Convert.ToInt32(numeric_VL.Value), Convert.ToInt32(numeric_VH.Value),
               checkBox_EH.Checked, checkBox_ES.Checked, checkBox_EV.Checked, checkBox_IV.Checked);

            if (iB2C == 0) imageBox2.Image = ImageFrameDetection;

            if (iB2C == 1)
            {
                Image<Bgr, Byte> imgF = new Image<Bgr, Byte>(ImageFrame.Width, ImageFrame.Height);
                Image<Bgr, Byte> imgD = ImageFrameDetection.Convert<Bgr, Byte>();
                CvInvoke.cvAnd(ImageFrame, imgD, imgF, IntPtr.Zero);
                imageBox2.Image = imgF;
            }

            if (iB2C == 2)
            {
                Image<Bgr, Byte> imgF = new Image<Bgr, Byte>(ImageFrame.Width, ImageFrame.Height);
                Image<Bgr, Byte> imgD = ImageFrameDetection.Convert<Bgr, Byte>();
                CvInvoke.cvAnd(ImageFrame, imgD, imgF, IntPtr.Zero);
                for (int x = 0; x < imgF.Width; x++)
                    for (int y = 0; y < imgF.Height; y++)
                    {
                        {
                            Bgr c = imgF[y, x];
                            if (c.Red == 0 && c.Blue == 0 && c.Green == 0)
                            {
                                imgF[y, x] = new Bgr(255, 255, 255);
                            }
                        }
                    }

                imageBox2.Image = imgF;
            }


            if (checkBox_VAr.Checked) RecDetection(ImageFrameDetection, ImageFrame, trackBar_VAr.Value);

            Image<Gray, Byte> ImageHSVwheelDetection = cvAndHsvImage(
               ImageHSVwheel,
               Convert.ToInt32(numeric_HL.Value), Convert.ToInt32(numeric_HH.Value),
               Convert.ToInt32(numeric_SL.Value), Convert.ToInt32(numeric_SH.Value),
               Convert.ToInt32(numeric_VL.Value), Convert.ToInt32(numeric_VH.Value),
               checkBox_EH.Checked, checkBox_ES.Checked, checkBox_EV.Checked, checkBox_IV.Checked);
            imageBox4.Image = ImageHSVwheelDetection;
        }

        #endregion

        #region Image Processing

        private void RecDetection(Image<Gray, Byte> img, Image<Bgr, Byte> showRecOnImg, int areaV)
        {
            Image<Gray, Byte> imgForContour = new Image<Gray, byte>(img.Width, img.Height);
            CvInvoke.cvCopy(img, imgForContour, System.IntPtr.Zero);


            IntPtr storage = CvInvoke.cvCreateMemStorage(0);
            IntPtr contour = new IntPtr();

            CvInvoke.cvFindContours(
                imgForContour,
                storage,
                ref contour,
                System.Runtime.InteropServices.Marshal.SizeOf(typeof(MCvContour)),
                Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_EXTERNAL,
                Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_NONE,
                new Point(0, 0));


            Seq<Point> seq = new Seq<Point>(contour, null);

            for (; seq != null && seq.Ptr.ToInt64() != 0; seq = seq.HNext)
            {
                Rectangle bndRec = CvInvoke.cvBoundingRect(seq, 2);
                double areaC = CvInvoke.cvContourArea(seq, MCvSlice.WholeSeq, 1) * -1;
                if (areaC > areaV)
                {
                    CvInvoke.cvRectangle(showRecOnImg, new Point(bndRec.X, bndRec.Y),
                        new Point(bndRec.X + bndRec.Width, bndRec.Y + bndRec.Height),
                        new MCvScalar(0, 0, 255), 2, LINE_TYPE.CV_AA, 0);
                }

            }

        }
        private Image<Gray, Byte> cvAndHsvImage(Image<Bgr, Byte> imgFame, int L1, int H1, int L2, int H2, int L3, int H3, bool H, bool S, bool V, bool I)
        {
            Image<Hsv, Byte> hsvImage = imgFame.Convert<Hsv, Byte>();
            Image<Gray, Byte> ResultImage = new Image<Gray, Byte>(hsvImage.Width, hsvImage.Height);
            Image<Gray, Byte> ResultImageH = new Image<Gray, Byte>(hsvImage.Width, hsvImage.Height);
            Image<Gray, Byte> ResultImageS = new Image<Gray, Byte>(hsvImage.Width, hsvImage.Height);
            Image<Gray, Byte> ResultImageV = new Image<Gray, Byte>(hsvImage.Width, hsvImage.Height);

            Image<Gray, Byte> img1 = inRangeImage(hsvImage, L1, H1, 0);
            Image<Gray, Byte> img2 = inRangeImage(hsvImage, L2, H2, 1);
            Image<Gray, Byte> img3 = inRangeImage(hsvImage, L3, H3, 2);
            Image<Gray, Byte> img4 = inRangeImage(hsvImage, 0, L1, 0);
            Image<Gray, Byte> img5 = inRangeImage(hsvImage, H1, 180, 0);

            #region checkBox Color Mode

            if (H)
            {
                if (I)
                {
                    CvInvoke.cvOr(img4, img5, img4, System.IntPtr.Zero);
                    ResultImageH = img4;
                }
                else { ResultImageH = img1; }
            }

            if (S) ResultImageS = img2;
            if (V) ResultImageV = img3;

            if (H && !S && !V) ResultImage = ResultImageH;
            if (!H && S && !V) ResultImage = ResultImageS;
            if (!H && !S && V) ResultImage = ResultImageV;

            if (H && S && !V)
            {
                CvInvoke.cvAnd(ResultImageH, ResultImageS, ResultImageH, System.IntPtr.Zero);
                ResultImage = ResultImageH;
            }

            if (H && !S && V)
            {
                CvInvoke.cvAnd(ResultImageH, ResultImageV, ResultImageH, System.IntPtr.Zero);
                ResultImage = ResultImageH;
            }

            if (!H && S && V)
            {
                CvInvoke.cvAnd(ResultImageS, ResultImageV, ResultImageS, System.IntPtr.Zero);
                ResultImage = ResultImageS;
            }

            if (H && S && V)
            {
                CvInvoke.cvAnd(ResultImageH, ResultImageS, ResultImageH, System.IntPtr.Zero);
                CvInvoke.cvAnd(ResultImageH, ResultImageV, ResultImageH, System.IntPtr.Zero);
                ResultImage = ResultImageH;
            }
            #endregion

            CvInvoke.cvErode(ResultImage, ResultImage, (IntPtr)null, 1);

            return ResultImage;
        }
        private Image<Gray, Byte> inRangeImage(Image<Hsv, Byte> hsvImage, int Lo, int Hi, int con)
        {
            Image<Gray, Byte> ResultImage = new Image<Gray, Byte>(hsvImage.Width, hsvImage.Height);
            Image<Gray, Byte> IlowCh = new Image<Gray, Byte>(hsvImage.Width, hsvImage.Height, new Gray(Lo));
            Image<Gray, Byte> IHiCh = new Image<Gray, Byte>(hsvImage.Width, hsvImage.Height, new Gray(Hi));
            CvInvoke.cvInRange(hsvImage[con], IlowCh, IHiCh, ResultImage);
            return ResultImage;
        }
        private int[] scaleImage(int wP, int hP)
        {
            int[] dR = new int[2];
            int ra;
            if (wP != 0)
            {
                ra = (100 * 320) / wP;
                wP = 320;
                hP = (hP * ra) / 100;
                if (hP != 0 && hP > 240)
                {
                    ra = (100 * 240) / hP;
                    hP = 240;
                    wP = (wP * ra) / 100;
                }
                dR[0] = wP;
                dR[1] = hP;
            }
            return dR;
        }

        #endregion

        #region // Tooth Even

        private void numeric_Lo_ValueChanged(object sender, EventArgs e)
        {
            trackBar_HL.Value = Convert.ToInt32(numeric_HL.Value);
            trackBar_SL.Value = Convert.ToInt32(numeric_SL.Value);
            trackBar_VL.Value = Convert.ToInt32(numeric_VL.Value);
        }
        private void numeric_Hi_ValueChanged(object sender, EventArgs e)
        {
            trackBar_HH.Value = Convert.ToInt32(numeric_HH.Value);
            trackBar_SH.Value = Convert.ToInt32(numeric_SH.Value);
            trackBar_VH.Value = Convert.ToInt32(numeric_VH.Value);

        }
        private void numeric_VAr_ValueChanged(object sender, EventArgs e)
        {
            trackBar_VAr.Value = Convert.ToInt32(numeric_VAr.Value);
        }

        private void trackBar_Lo_ValueChanged(object sender, EventArgs e)
        {
            if (trackBar_HL.Value >= trackBar_HH.Value && !checkBox_LH.Checked)
                trackBar_HH.Value = trackBar_HL.Value;
            if (checkBox_LH.Checked && trackBar_HL.Value + diff_LH <= 180)
                trackBar_HH.Value = trackBar_HL.Value + diff_LH;
            numeric_HL.Value = trackBar_HL.Value;
            numeric_SL.Value = trackBar_SL.Value;
            numeric_VL.Value = trackBar_VL.Value;
        }
        private void trackBar_Hi_ValueChanged(object sender, EventArgs e)
        {
            if (trackBar_HH.Value <= trackBar_HL.Value && !checkBox_LH.Checked)
                trackBar_HL.Value = trackBar_HH.Value;

            if (checkBox_LH.Checked && trackBar_HH.Value - diff_LH >= 0)
                trackBar_HL.Value = trackBar_HH.Value - diff_LH;

            numeric_HH.Value = trackBar_HH.Value;
            numeric_SH.Value = trackBar_SH.Value;
            numeric_VH.Value = trackBar_VH.Value;
        }
        private void trackBar_VAr_ValueChanged(object sender, EventArgs e)
        {
            numeric_VAr.Value = trackBar_VAr.Value;
        }

        private void checkBox_LH_CheckedChanged(object sender, EventArgs e)
        {
            diff_LH = trackBar_HH.Value - trackBar_HL.Value;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            imageInProgress = false;

            if (capture == null)
            {
                try
                {
                    capture = new Capture();
                }
                catch (NullReferenceException excpt)
                {
                    MessageBox.Show(excpt.Message);
                }
            }

            if (capture != null)
            {
                if (captureInProgress)
                {
                    captureInProgress = false;
                }
                else
                {
                    captureInProgress = true;
                }
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            captureInProgress = false;
            OpenFileDialog OpenFile = new OpenFileDialog();
            if (OpenFile.ShowDialog() == DialogResult.OK)
            {
                filenameload = OpenFile.FileName;
                imageInProgress = true;
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void button5_Click(object sender, EventArgs e)
        {
            trackBar_HH.Value = 0;
            trackBar_HL.Value = 0;
            trackBar_SH.Value = 255;
            trackBar_SL.Value = 0;
            trackBar_VH.Value = 255;
            trackBar_VL.Value = 0;
            checkBox_LH.Checked = false;
            checkBox_IV.Checked = false;

        }

        bool ib3C;
        int ib3C_HV, ib3C_Lable_X, ib3C_Lable_Y;
        private void imageBox3_MouseClick(object sender, MouseEventArgs e)
        {
            Image<Hsv, Byte> imgHsv = ImageHSVwheel.Convert<Hsv, Byte>();
            Hsv hsv = imgHsv[e.Y, e.X];
            if (!ib3C)
            {
                ib3C_HV = Convert.ToInt32(hsv.Hue);
                ib3C_Lable_X = imageBox3.Location.X + e.X;
                ib3C_Lable_Y = imageBox3.Location.Y + e.Y;
                label_L.Location = new Point(ib3C_Lable_X, ib3C_Lable_Y);
                label_H.Hide();
            }
            if (ib3C)
            {
                label_H.Show();
                if (ib3C_HV < hsv.Hue)
                {
                    trackBar_HL.Value = ib3C_HV;
                    trackBar_HH.Value = Convert.ToInt32(hsv.Hue);
                    label_H.Location = new Point(imageBox3.Location.X + e.X, imageBox3.Location.Y + e.Y);                   
                }
                else
                {
                    trackBar_HH.Value = ib3C_HV;
                    trackBar_HL.Value = Convert.ToInt32(hsv.Hue);
                    ib3C_HV = 0;
                    label_H.Location = new Point(ib3C_Lable_X, ib3C_Lable_Y);
                    label_L.Location = new Point(imageBox3.Location.X + e.X, imageBox3.Location.Y + e.Y);
                }
            }
            ib3C = !ib3C;
        }

        int iB2C;
        private void imageBox2_Click(object sender, EventArgs e)
        {
            iB2C++;
            if (iB2C > 2) iB2C = 0;
        }

        #endregion

    }
}



Visual Studio Express 2012*  http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products
Emgu CV Library* http://www.emgu.com/wiki/index.php/Main_Page
Open CV* http://opencv.org/
processing * http://www.processing.org/


:'(

ไอ้โน่ นอนรอ พ่อมันจบหลักสูตร..