소스 검색

add: 摄像头预览程序(jpg版),扩展支持air724的摄像头预览

Wendal Chen 3 년 전
부모
커밋
ad3b4ecd2f
2개의 변경된 파일26개의 추가작업 그리고 6개의 파일을 삭제
  1. 5 5
      usb_camera_winform/Form1.Designer.cs
  2. 21 1
      usb_camera_winform/Form1.cs

+ 5 - 5
usb_camera_winform/Form1.Designer.cs

@@ -42,9 +42,9 @@
             // pictureBox_main
             // 
             this.pictureBox_main.BackColor = System.Drawing.SystemColors.ControlDark;
-            this.pictureBox_main.Location = new System.Drawing.Point(60, 93);
+            this.pictureBox_main.Location = new System.Drawing.Point(12, 96);
             this.pictureBox_main.Name = "pictureBox_main";
-            this.pictureBox_main.Size = new System.Drawing.Size(240, 320);
+            this.pictureBox_main.Size = new System.Drawing.Size(640, 480);
             this.pictureBox_main.TabIndex = 0;
             this.pictureBox_main.TabStop = false;
             // 
@@ -72,7 +72,7 @@
             // label_data_log
             // 
             this.label_data_log.AutoSize = true;
-            this.label_data_log.Location = new System.Drawing.Point(12, 438);
+            this.label_data_log.Location = new System.Drawing.Point(13, 604);
             this.label_data_log.Name = "label_data_log";
             this.label_data_log.Size = new System.Drawing.Size(69, 20);
             this.label_data_log.TabIndex = 4;
@@ -118,7 +118,7 @@
             this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.SystemColors.Control;
-            this.ClientSize = new System.Drawing.Size(368, 475);
+            this.ClientSize = new System.Drawing.Size(666, 719);
             this.Controls.Add(this.textBox_br);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.button2);
@@ -129,7 +129,7 @@
             this.Controls.Add(this.pictureBox_main);
             this.MaximizeBox = false;
             this.Name = "Form1";
-            this.Text = "Air105摄像头预览";
+            this.Text = "LuatOS摄像头预览";
             this.Load += new System.EventHandler(this.Form1_Load);
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox_main)).EndInit();
             this.ResumeLayout(false);

+ 21 - 1
usb_camera_winform/Form1.cs

@@ -19,6 +19,15 @@ namespace Air105摄像头预览
             thread.IsBackground = true;
         }
 
+        public  void record_uart_data(byte[] buff, int offset, int size)
+        {
+            String path = "uart.dat";
+            using (FileStream FS = new FileStream(path, File.Exists(path) ? FileMode.Append : FileMode.OpenOrCreate, FileAccess.Write))
+            {
+                FS.Write(buff, offset, size);
+                FS.Close();
+            }
+        }
         private void Form1_Load(object sender, EventArgs e)
         {
             reload_com_names();
@@ -52,7 +61,7 @@ namespace Air105摄像头预览
         void Run_mac_flasher()
         {
             Thread.Sleep(1000);
-            var buff = new byte[64 * 1024];
+            var buff = new byte[16 * 1024 * 1024];
             while (true)
             {
                 if (comName == "" || power_ready == false)
@@ -87,6 +96,7 @@ namespace Air105摄像头预览
                 }
                 if (rlen > 0)
                 {
+                    record_uart_data(buff, 0, rlen);
                     if (buff[0] == 'A' && buff[1] == 'i' && buff[2] == 'r')
                     {
                         for (int i = 0; i < buff.Length; i++)
@@ -114,6 +124,15 @@ namespace Air105摄像头预览
                                     }));
                                     break;
                                 }
+                                if (dataRequire > 16*1024*1024)
+                                {
+                                    text = "最大支持16M的图片";
+                                    this.label_data_log.BeginInvoke(new Action(() =>
+                                    {
+                                        this.label_data_log.Text = text;
+                                    }));
+                                    break;
+                                }
                                 //var dataRecv = rlen;
                                 while (rlen < dataRequire + i + 2)
                                 {
@@ -121,6 +140,7 @@ namespace Air105摄像头预览
                                     if (len2 > 0)
                                     {
                                         rlen += len2;
+                                        record_uart_data(buff, rlen, len2);
                                     }
                                     else if (len2 < 0)
                                     {