在本文中,我们将带你了解如何在未找到编解码器的Windows计算机上使用opencv在这篇文章中,我们将为您详细介绍如何在未找到编解码器的Windows计算机上使用opencv的方方面面,并解答找不到
在本文中,我们将带你了解如何在未找到编解码器的Windows计算机上使用opencv在这篇文章中,我们将为您详细介绍如何在未找到编解码器的Windows计算机上使用opencv的方方面面,并解答找不到所需的编解码器常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的C#编写的windows计算器的实例代码、FFMPEG - 在流 #0 中找不到编解码器 pcm_s16le 的标签,容器当前不支持编解码器、java – 在计算机上将C opencv项目转换为opencv android的步骤、MediaCodec如何在Android框架内找到编解码器?。
本文目录一览:- 如何在未找到编解码器的Windows计算机上使用opencv(找不到所需的编解码器)
- C#编写的windows计算器的实例代码
- FFMPEG - 在流 #0 中找不到编解码器 pcm_s16le 的标签,容器当前不支持编解码器
- java – 在计算机上将C opencv项目转换为opencv android的步骤
- MediaCodec如何在Android框架内找到编解码器?
如何在未找到编解码器的Windows计算机上使用opencv(找不到所需的编解码器)
如何解决如何在未找到编解码器的Windows计算机上使用opencv?
嗨,我正在尝试编写一个程序,该程序可以检测到我握在网络摄像头上的颜色,然后当我移动颜色时,计算机应该画一条线:我正在遵循本教程:https://www.youtube.com/watch?v=WQeoO7MI0Bs 我的代码:
import cv2
import numpy as np
frameWidth = 640
frameHieght = 480
cap = cv2.VideoCapture(0)
cap.set(3,frameWidth)
cap.set(4,frameHieght)
cap.set(10,150)
myColors = [[5,107,19,255,255],# orange
[133,56,159,156,# purple
[57,76,100,255]] # green
def findcolor(img,myColors):
imgSHV = cv2.cvtColor(img)
lower = np.array(myColors[0][0:3])
upper = np.array(myColors[0][3:6])
mask = cv2.inRange(imgSHV,lower,upper)
cv2.imshow("img",mask)
while True:
success,img = cap.read()
findcolor(img,myColors)
cv2.imshow(''Result'',img)
if cv2.waitKey(1) & 0xFF == ord(''q''):
break
在我的第一台笔记本电脑上,它说未找到MFViedeo Format(codec),在我的第二台笔记本电脑上,它说了ModuleNotFoundError:没有名为“ cv2.cv2”的模块。当我尝试通过jupyter notebook和spyder运行代码时,它说python停止工作。 我还尝试了以下代码来访问我的相机,但是它提供了相同的ModuleNotFoundError:没有名为“ cv2.cv2”的模块,并且python停止工作。这是代码:
import cv2
cap = cv2.VideoCapture(0)
while True:
ret,frame = cap.read()
gray = cv2.cvtColor(frame,cv2.COLOR_BAYER_BG2BGR)
cv2.imshow(''frame'',frame)
if cv2.waitKey(1) & 0xff == ord(''q''):
break
cap.release()
cv2.destroyAllWindows()
当我在Windows 10 PC上尝试相同的代码时,它说:--------------------------------- ------------------------------------------
error Traceback (most recent call last)
<ipython-input-15-88911053ec4b> in <module>
26 while True:
27 success,img = cap.read()
---> 28 findcolor(img,myColors)
29 cv2.imshow(''Result'',img)
30 if cv2.waitKey(1) & 0xFF == ord(''q''):
<ipython-input-15-88911053ec4b> in findcolor(img,myColors)
17
18 def findcolor(img,myColors):
---> 19 imgSHV = cv2.cvtColor(img,cv2.COLOR_BAYER_BG2BGR)
20 lower = np.array(myColors[0][0:3])
21 upper = np.array(myColors[0][3:6])
错误:OpenCV(4.4.0)C:\ Users \ app_ey * r \ AppData \ Local \ Temp \ 1 \ pip-re_-build-2y91i_7w \ opencv \ modules \ imgproc \ src \ demosaicing.cpp:1721:错误:函数''cv :: demosaicing''中的(-215:声明失败)scn == 1 &&(dcn == 3 || dcn == 4)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
C#编写的windows计算器的实例代码
using System;
using System.Drawing;
using System.Windows;
using System.Windows.Forms;
using System.Collections;
using System.ComponentModel;
using System.Data;
namespace comput
{
/// <summary>
/// 这是一个计算器的简单实现。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
#region 控件声明
private System.Windows.Forms.TextBox txtShow;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btn_rev;
private System.Windows.Forms.Button btn_dot;
private System.Windows.Forms.Button btn_add;
private System.Windows.Forms.Button btn_equ;
private System.Windows.Forms.Button btn_sign;
private System.Windows.Forms.Button btn_sub;
private System.Windows.Forms.Button btn_mul;
private System.Windows.Forms.Button btn_0;
private System.Windows.Forms.Button btn_3;
private System.Windows.Forms.Button btn_2;
private System.Windows.Forms.Button btn_1;
private System.Windows.Forms.Button btn_6;
private System.Windows.Forms.Button btn_5;
private System.Windows.Forms.Button btn_4;
private System.Windows.Forms.Button btn_sqrt;
private System.Windows.Forms.Button btn_div;
private System.Windows.Forms.Button btn_7;
private System.Windows.Forms.Button btn_8;
private System.Windows.Forms.Button btn_9;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.Button btn_sqr;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.Button c;
private System.Windows.Forms.Button ce;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.MenuItem menuItem10;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// Todo: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.dispose();
}
}
base.dispose( disposing );
}
#endregion
#region 各控件的属性的方法Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.txtShow = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.c = new System.Windows.Forms.Button();
this.ce = new System.Windows.Forms.Button();
this.btn_rev = new System.Windows.Forms.Button();
this.btn_dot = new System.Windows.Forms.Button();
this.btn_add = new System.Windows.Forms.Button();
this.btn_equ = new System.Windows.Forms.Button();
this.btn_sign = new System.Windows.Forms.Button();
this.btn_sub = new System.Windows.Forms.Button();
this.btn_mul = new System.Windows.Forms.Button();
this.btn_0 = new System.Windows.Forms.Button();
this.btn_3 = new System.Windows.Forms.Button();
this.btn_2 = new System.Windows.Forms.Button();
this.btn_1 = new System.Windows.Forms.Button();
this.btn_6 = new System.Windows.Forms.Button();
this.btn_5 = new System.Windows.Forms.Button();
this.btn_4 = new System.Windows.Forms.Button();
this.btn_sqrt = new System.Windows.Forms.Button();
this.btn_div = new System.Windows.Forms.Button();
this.btn_7 = new System.Windows.Forms.Button();
this.btn_8 = new System.Windows.Forms.Button();
this.btn_9 = new System.Windows.Forms.Button();
this.btn_sqr = new System.Windows.Forms.Button();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// txtShow
//
this.txtShow.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)),((System.Byte)(192)),((System.Byte)(255)));
this.txtShow.Font = new System.Drawing.Font("宋体",10.5F,System.Drawing.FontStyle.Regular,system.drawing.graphicsUnit.Point,((System.Byte)(134)));
this.txtShow.ForeColor = System.Drawing.Color.Purple;
this.txtShow.Location = new System.Drawing.Point(25,8);
this.txtShow.Name = "txtShow";
this.txtShow.Size = new System.Drawing.Size(228,23);
this.txtShow.TabIndex = 1;
this.txtShow.Text = "0.";
this.txtShow.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.c);
this.groupBox1.Controls.Add(this.ce);
this.groupBox1.Controls.Add(this.btn_rev);
this.groupBox1.Controls.Add(this.btn_dot);
this.groupBox1.Controls.Add(this.btn_add);
this.groupBox1.Controls.Add(this.btn_equ);
this.groupBox1.Controls.Add(this.btn_sign);
this.groupBox1.Controls.Add(this.btn_sub);
this.groupBox1.Controls.Add(this.btn_mul);
this.groupBox1.Controls.Add(this.btn_0);
this.groupBox1.Controls.Add(this.btn_3);
this.groupBox1.Controls.Add(this.btn_2);
this.groupBox1.Controls.Add(this.btn_1);
this.groupBox1.Controls.Add(this.btn_6);
this.groupBox1.Controls.Add(this.btn_5);
this.groupBox1.Controls.Add(this.btn_4);
this.groupBox1.Controls.Add(this.btn_sqrt);
this.groupBox1.Controls.Add(this.btn_div);
this.groupBox1.Controls.Add(this.btn_7);
this.groupBox1.Controls.Add(this.btn_8);
this.groupBox1.Controls.Add(this.btn_9);
this.groupBox1.Controls.Add(this.btn_sqr);
this.groupBox1.Location = new System.Drawing.Point(24,40);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(232,184);
this.groupBox1.TabIndex = 21;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "计算机区";
//
// c
//
this.c.Font = new System.Drawing.Font("宋体",System.Drawing.FontStyle.Bold,((System.Byte)(134)));
this.c.ForeColor = System.Drawing.Color.Red;
this.c.Location = new System.Drawing.Point(178,48);
this.c.Name = "c";
this.c.Size = new System.Drawing.Size(36,61);
this.c.TabIndex = 41;
this.c.Text = "C";
this.c.Click += new System.EventHandler(this.btn_Oper);
//
// ce
//
this.ce.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.ce.ForeColor = System.Drawing.Color.Red;
this.ce.Location = new System.Drawing.Point(138,16);
this.ce.Name = "ce";
this.ce.Size = new System.Drawing.Size(76,29);
this.ce.TabIndex = 40;
this.ce.Text = "CE";
this.ce.Click += new System.EventHandler(this.btn_Oper);
//
// btn_rev
//
this.btn_rev.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_rev.ForeColor = System.Drawing.Color.Blue;
this.btn_rev.Location = new System.Drawing.Point(178,112);
this.btn_rev.Name = "btn_rev";
this.btn_rev.Size = new System.Drawing.Size(36,29);
this.btn_rev.TabIndex = 39;
this.btn_rev.Text = "1/x";
this.btn_rev.Click += new System.EventHandler(this.btn_Oper);
//
// btn_dot
//
this.btn_dot.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_dot.Location = new System.Drawing.Point(98,144);
this.btn_dot.Name = "btn_dot";
this.btn_dot.Size = new System.Drawing.Size(36,29);
this.btn_dot.TabIndex = 38;
this.btn_dot.Tag = "0";
this.btn_dot.Text = ".";
this.btn_dot.Click += new System.EventHandler(this.btn_Oper);
//
// btn_add
//
this.btn_add.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_add.ForeColor = System.Drawing.Color.Red;
this.btn_add.Location = new System.Drawing.Point(138,144);
this.btn_add.Name = "btn_add";
this.btn_add.Size = new System.Drawing.Size(36,29);
this.btn_add.TabIndex = 37;
this.btn_add.Text = "+";
this.btn_add.Click += new System.EventHandler(this.btn_Oper);
//
// btn_equ
//
this.btn_equ.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_equ.ForeColor = System.Drawing.Color.Red;
this.btn_equ.Location = new System.Drawing.Point(178,144);
this.btn_equ.Name = "btn_equ";
this.btn_equ.Size = new System.Drawing.Size(36,29);
this.btn_equ.TabIndex = 36;
this.btn_equ.Text = "=";
this.btn_equ.Click += new System.EventHandler(this.btn_equ_Click);
//
// btn_sign
//
this.btn_sign.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_sign.ForeColor = System.Drawing.Color.Blue;
this.btn_sign.Location = new System.Drawing.Point(58,144);
this.btn_sign.Name = "btn_sign";
this.btn_sign.Size = new System.Drawing.Size(36,29);
this.btn_sign.TabIndex = 35;
this.btn_sign.Text = "+/-";
this.btn_sign.Click += new System.EventHandler(this.btn_Oper);
//
// btn_sub
//
this.btn_sub.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_sub.ForeColor = System.Drawing.Color.Red;
this.btn_sub.Location = new System.Drawing.Point(138,112);
this.btn_sub.Name = "btn_sub";
this.btn_sub.Size = new System.Drawing.Size(36,29);
this.btn_sub.TabIndex = 34;
this.btn_sub.Text = "-";
this.btn_sub.Click += new System.EventHandler(this.btn_Oper);
//
// btn_mul
//
this.btn_mul.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_mul.ForeColor = System.Drawing.Color.Red;
this.btn_mul.Location = new System.Drawing.Point(138,80);
this.btn_mul.Name = "btn_mul";
this.btn_mul.Size = new System.Drawing.Size(36,29);
this.btn_mul.TabIndex = 33;
this.btn_mul.Text = "*";
this.btn_mul.Click += new System.EventHandler(this.btn_Oper);
//
// btn_0
//
this.btn_0.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_0.ForeColor = System.Drawing.Color.Blue;
this.btn_0.Location = new System.Drawing.Point(18,144);
this.btn_0.Name = "btn_0";
this.btn_0.Size = new System.Drawing.Size(36,29);
this.btn_0.TabIndex = 32;
this.btn_0.Tag = "0";
this.btn_0.Text = "0";
this.btn_0.Click += new System.EventHandler(this.btn_0_Click);
//
// btn_3
//
this.btn_3.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_3.ForeColor = System.Drawing.Color.Blue;
this.btn_3.Location = new System.Drawing.Point(98,112);
this.btn_3.Name = "btn_3";
this.btn_3.Size = new System.Drawing.Size(36,29);
this.btn_3.TabIndex = 31;
this.btn_3.Tag = "3";
this.btn_3.Text = "3";
this.btn_3.Click += new System.EventHandler(this.btn_0_Click);
//
// btn_2
//
this.btn_2.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_2.ForeColor = System.Drawing.Color.Blue;
this.btn_2.Location = new System.Drawing.Point(58,112);
this.btn_2.Name = "btn_2";
this.btn_2.Size = new System.Drawing.Size(36,29);
this.btn_2.TabIndex = 30;
this.btn_2.Tag = "2";
this.btn_2.Text = "2";
this.btn_2.Click += new System.EventHandler(this.btn_0_Click);
//
// btn_1
//
this.btn_1.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_1.ForeColor = System.Drawing.Color.Blue;
this.btn_1.Location = new System.Drawing.Point(18,112);
this.btn_1.Name = "btn_1";
this.btn_1.Size = new System.Drawing.Size(36,29);
this.btn_1.TabIndex = 29;
this.btn_1.Tag = "1";
this.btn_1.Text = "1";
this.btn_1.Click += new System.EventHandler(this.btn_0_Click);
//
// btn_6
//
this.btn_6.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_6.ForeColor = System.Drawing.Color.Blue;
this.btn_6.Location = new System.Drawing.Point(98,80);
this.btn_6.Name = "btn_6";
this.btn_6.Size = new System.Drawing.Size(36,29);
this.btn_6.TabIndex = 28;
this.btn_6.Tag = "6";
this.btn_6.Text = "6";
this.btn_6.Click += new System.EventHandler(this.btn_0_Click);
//
// btn_5
//
this.btn_5.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_5.ForeColor = System.Drawing.Color.Blue;
this.btn_5.Location = new System.Drawing.Point(58,80);
this.btn_5.Name = "btn_5";
this.btn_5.Size = new System.Drawing.Size(36,29);
this.btn_5.TabIndex = 27;
this.btn_5.Tag = "5";
this.btn_5.Text = "5";
this.btn_5.Click += new System.EventHandler(this.btn_0_Click);
//
// btn_4
//
this.btn_4.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_4.ForeColor = System.Drawing.Color.Blue;
this.btn_4.Location = new System.Drawing.Point(18,80);
this.btn_4.Name = "btn_4";
this.btn_4.Size = new System.Drawing.Size(36,29);
this.btn_4.TabIndex = 26;
this.btn_4.Tag = "4";
this.btn_4.Text = "4";
this.btn_4.Click += new System.EventHandler(this.btn_0_Click);
//
// btn_sqrt
//
this.btn_sqrt.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_sqrt.ForeColor = System.Drawing.Color.Blue;
this.btn_sqrt.Location = new System.Drawing.Point(18,16);
this.btn_sqrt.Name = "btn_sqrt";
this.btn_sqrt.Size = new System.Drawing.Size(76,29);
this.btn_sqrt.TabIndex = 25;
this.btn_sqrt.Text = "sqrt";
this.btn_sqrt.Click += new System.EventHandler(this.btn_Oper);
//
// btn_div
//
this.btn_div.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_div.ForeColor = System.Drawing.Color.Red;
this.btn_div.Location = new System.Drawing.Point(138,48);
this.btn_div.Name = "btn_div";
this.btn_div.Size = new System.Drawing.Size(36,29);
this.btn_div.TabIndex = 24;
this.btn_div.Text = "/";
this.btn_div.Click += new System.EventHandler(this.btn_Oper);
//
// btn_7
//
this.btn_7.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_7.ForeColor = System.Drawing.Color.Blue;
this.btn_7.Location = new System.Drawing.Point(18,48);
this.btn_7.Name = "btn_7";
this.btn_7.Size = new System.Drawing.Size(36,29);
this.btn_7.TabIndex = 23;
this.btn_7.Tag = "7";
this.btn_7.Text = "7";
this.btn_7.Click += new System.EventHandler(this.btn_0_Click);
//
// btn_8
//
this.btn_8.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_8.ForeColor = System.Drawing.Color.Blue;
this.btn_8.Location = new System.Drawing.Point(58,48);
this.btn_8.Name = "btn_8";
this.btn_8.Size = new System.Drawing.Size(36,29);
this.btn_8.TabIndex = 22;
this.btn_8.Tag = "8";
this.btn_8.Text = "8";
this.btn_8.Click += new System.EventHandler(this.btn_0_Click);
//
// btn_9
//
this.btn_9.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_9.ForeColor = System.Drawing.Color.Blue;
this.btn_9.Location = new System.Drawing.Point(98,48);
this.btn_9.Name = "btn_9";
this.btn_9.Size = new System.Drawing.Size(36,29);
this.btn_9.TabIndex = 21;
this.btn_9.Tag = "9";
this.btn_9.Text = "9";
this.btn_9.Click += new System.EventHandler(this.btn_0_Click);
//
// btn_sqr
//
this.btn_sqr.Font = new System.Drawing.Font("宋体",((System.Byte)(134)));
this.btn_sqr.ForeColor = System.Drawing.Color.Blue;
this.btn_sqr.Location = new System.Drawing.Point(98,16);
this.btn_sqr.Name = "btn_sqr";
this.btn_sqr.Size = new System.Drawing.Size(36,29);
this.btn_sqr.TabIndex = 19;
this.btn_sqr.Text = "sqr";
this.btn_sqr.Click += new System.EventHandler(this.btn_Oper);
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem8,
this.menuItem1,
this.menuItem4});
//
// menuItem1
//
this.menuItem1.Index = 1;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2,
this.menuItem3});
this.menuItem1.Text = "编辑(&E)";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "复制(&C)";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem3
//
this.menuItem3.Index = 1;
this.menuItem3.Text = "粘贴(&P)";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem4
//
this.menuItem4.Index = 2;
this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem5,
this.menuItem6});
this.menuItem4.Text = "帮助(&H)";
//
// menuItem5
//
this.menuItem5.Index = 0;
this.menuItem5.Text = "帮助主题(&H)";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuItem6
//
this.menuItem6.Index = 1;
this.menuItem6.Text = "关于(&A)";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem8
//
this.menuItem8.Index = 0;
this.menuItem8.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem9,
this.menuItem10});
this.menuItem8.Text = "文件(&F)";
//
// menuItem9
//
this.menuItem9.Index = 0;
this.menuItem9.Text = "打开windows计算器(&O)";
this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
//
// menuItem10
//
this.menuItem10.Index = 1;
this.menuItem10.Text = "退出(&Q)";
this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6,14);
this.ClientSize = new System.Drawing.Size(278,239);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.txtShow);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Icon = ((System.Drawing.Icon)(resources.Getobject("$this.Icon")));
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "计算器";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
#region 各变量和常数的声明
public const int NULL = 0; // 定义操作码
public const int ADD = 1; //表示加
public const int SUB = 2; //减
public const int MUL = 3; //乘
public const int DIV = 4; //除
public const int SQR = 5; //求平方
public const int SQRT = 6; //求平方根
public const int NodoT = 0; // 定义是否点击了小数点,0 为没点
public const int HASDOT = 1;
private double res = 0; // 记录结果数
private double tmp = 0; // 当前输入的操作数
private int opt = NULL; // 记录操作码
private int dot = NodoT; // 记录是否点击了小数点,0为没有点
private int num = 0; // 记录输入操作数的个数
private int dotnum = 0; // 记录小数点部分的个数
string strOper; //获取操作符
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
/// <summary>
#region 获取操作数事件
//获取操作数事件
private void btn_0_Click(object sender,System.EventArgs e)
{
System.Windows.Forms.Button btnTmp;
double i;
btnTmp = sender as System.Windows.Forms.Button;
if (btnTmp != null)
{
if (dot == NodoT)
{
// 没有点击小数点
i = double.Parse(btnTmp.Tag.ToString()); //取用户自定义的控件关联数,并转换成double型
tmp = tmp * 10 + i;
txtShow.Text = tmp.ToString(); //将其放入文本显示屏啊
}
else // 点击了小数点
{
dotnum++; //记录小数点部分的个数
// 生成小数部分的新的数值
i = double.Parse(btnTmp.Tag.ToString()) / System.Math.Pow(10,dotnum);
tmp = tmp + i; //将小数点后的值加到当前操做数
txtShow.Text = tmp.ToString();
}
}
}
#endregion
#region 等于事件和等于运算方法
//等于事件
private void btn_equ_Click(object sender,System.EventArgs e)
{
calc();
}
//等于运算方法
private void calc()
{
// 生成结果
if (num == 0 ) //是否有操作数,没有就返回0
{
res = 0;
tmp = 0;
txtShow.Text = res.ToString();
return;
}
switch (opt) //找到对应的运算符进行计算
{
// 加法
case ADD:
res = res + tmp;
break;
// 减法
case SUB:
res = res - tmp;
break;
// 乘法
case MUL:
res = res * tmp;
break;
// 除法
case DIV:
res = res / tmp;
break;
// 平方
case SQR:
res = tmp * tmp;
break;
// 平方根
case SQRT:
res = System.Math.Sqrt(tmp);
break;
default:
return;
}
txtShow.Text = res.ToString(); //结果输出到文本显示屏
opt = NULL; //运算符清空
tmp=0;
dot = NodoT;
//res = 0;
//num = 0;
}
#endregion
#region 获取操作符运事件
//获取操作符运事件
private void btn_Oper(object obj,EventArgs ea)
{
Button tmp1=(Button)obj;
strOper=tmp1.Text;
switch (strOper)
{
case "/": //除法运算
if(opt!=NULL&&opt!=DIV)
{
calc();
}
opt = DIV;
if (num != 0) //判断操作数的个数,如果两个就做二元运算
{
if (tmp != 0)
res = res / tmp;
}
else
res = tmp;
num++;
tmp = 0;
txtShow.Text = res.ToString();
dot = NodoT;
break;
case "*":
// 乘法运算
if(opt!=NULL&&opt!=MUL)
{
calc();
}
opt = MUL;
if (num!= 0 ) //判断操作数的个数,如果两个就做二元运算
{
if(tmp!=0)
res = res * tmp;
}
else
res = tmp;
num++;
tmp = 0;
txtShow.Text = res.ToString();
dot = NodoT;
break;
case "+": //加法运算
if(opt!=NULL&&opt!=ADD)
{
calc();
}
opt = ADD;
if (num != 0) //判断操作数的个数,如果两个就做二元运算
res = res + tmp;
else
res = tmp;
num++;
tmp = 0;
txtShow.Text = res.ToString();
dot = NodoT;
break;
case "-": //减法运算
if(opt!=NULL&&opt!=SUB)
{
calc();
}
/*if(opt==ADD)
{
res=res+tmp;
tmp=0;
}*/
opt = SUB;
if (num != 0) //判断操作数的个数,如果两个就做二元运算
res = res - tmp;
else
res = tmp;
num++;
tmp = 0;
txtShow.Text = res.ToString();
dot = NodoT;
break;
case "sqrt": //平方根运算
if(opt!=NULL)
{
calc();
}
//opt=SQRT;
if (tmp > 0) //要求操作数大于0
{
res = Math.Sqrt(tmp);
//res=tmp;
}
else if(res>0)
res= Math.Sqrt(res);
txtShow.Text =res.ToString();
num++;
tmp=0;
dot = NodoT;
break;
case "sqr":
// 平方运算
if(opt!=NULL)
{
calc();
}
//opt=SQR;
if (tmp != 0)
{
res = tmp * tmp;
//res=tmp;
}
else
res=res*res;
txtShow.Text = res.ToString();
num++;
tmp=0;
dot = NodoT;
break;
case "1/x": //倒数运算
if(opt!=NULL)
{
calc();
}
if (tmp != 0)
{
res = 1 / tmp;
//res=tmp;
}
else
res=1/res;
txtShow.Text = res.ToString();
tmp=0;
dot = NodoT;
break;
case ".":
// 点击了小数点
if(dot==HASDOT)
return;
else
{
dot = HASDOT;
dotnum = 0;
}
break;
case "+/-":
// 点击了符号运算
if(tmp!=0)
{
tmp = -tmp;
txtShow.Text = tmp.ToString();
}
else
{
res=-res;
//res=tmp;
txtShow.Text = res.ToString();
}
dot = NodoT;
break;
case "CE": //清除运算
res = 0; // 记录结果数
tmp = 0; // 当前输入的操作数
opt = NULL; // 记录操作码
dot = NodoT; // 记录是否点击了小数点
num = 0; // 记录输入操作数的个数
dotnum = 0; // 记录小数点部分的个数
txtShow.Text="";
break;
case "C": //清除运算
res = 0; // 记录结果数
tmp = 0; // 当前输入的操作数
opt = NULL; // 记录操作码
dot = NodoT; // 记录是否点击了小数点
num = 0; // 记录输入操作数的个数
dotnum = 0; // 记录小数点部分的个数
txtShow.Text="";
break;
}
}
#endregion
#region 主菜单事件
//打开关于主题---调用windows xp中计算器的帮助
private void menuItem5_Click(object sender,System.EventArgs e)
{
Help.ShowHelp(this,"C:\\WINDOWS\\Help\\calc.chm");
}
//打开于我们
private void menuItem6_Click(object sender,System.EventArgs e)
{
Form2 fm=new Form2();
fm.Show();
}
//复制
private void menuItem2_Click(object sender,System.EventArgs e)
{
if(txtShow.SelectionLength>0)
{
txtShow.copy();
}
}
//
//粘贴
private void menuItem3_Click(object sender,System.EventArgs e)
{
txtShow.Paste();
}
//调用windows xp中的计算器
private void menuItem9_Click(object sender,System.EventArgs e)
{
Help.ShowHelp(this,"C:\\WINDOWS\\system32\\calc.exe");
}
//退出
private void menuItem10_Click(object sender,System.EventArgs e)
{
Application.Exit();
}
#endregion
}
}
PS:这里再为大家推荐两款本站的在线计算器,都是采用js实现,相信对大家有一定借鉴作用:
在线标准计算器:http://tools.jb51.net/jisuanqi/jsq
在线科学计算器:http://tools.jb51.net/jisuanqi/jsqkexue
FFMPEG - 在流 #0 中找不到编解码器 pcm_s16le 的标签,容器当前不支持编解码器
如何解决FFMPEG - 在流 #0 中找不到编解码器 pcm_s16le 的标签,容器当前不支持编解码器?
我正在使用以下命令提取部分单声道 44K .M4A 音频文件;
ffmpeg -ss 00:00:01 -i input.m4a -t 00:00:03 -c:a copy output.m4a
但我收到以下错误;
Trailing option(s) found in the command: may be ignored.
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0,wav,from ''input.m4a'':
Duration: 00:00:01.95,bitrate: 705 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001),44100 Hz,mono,s16,705 kb/s
[ipod @ 00000222e439ca00] Could not find tag for codec pcm_s16le in stream #0,codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Stream mapping:
Stream #0:0 -> #0:0 (copy)
我注意到 FFMPEG 猜测我的文件是 wav 但这很奇怪,因为我认为它是 .M4A 。那么 FFMPEG 是否错误地猜测我的输入是 wav 文件并因此产生错误?
解决方法
这似乎是解决方案;
ffmpeg -ss 00:00:01 -i input.m4a -t 00:00:03 -c:a aac output.m4a
但我仍然想知道为什么我的 .m4a 文件被检测为 wav。
java – 在计算机上将C opencv项目转换为opencv android的步骤
我在计算机上编写了一个c项目,用于使用OpenCV稳定视频.但我想用Opencv4Android将这个项目编写到android.为此,我应该制作新项目还是以任何方式使用NDK将该项目转换为android?如果我可以使用mycompter的项目,那c代码需要进行很多更改吗?将计算机opencv项目转换或移植到android opencv项目需要哪些步骤?
解决方法:
这是一个非常普遍的问题,所以我会尝试将其分解一下.
首先,让我们暂时忘掉openCV.
您想为Android创建一个c项目.在为Android构建c代码时,可以通过NDK构建它.我建议你从这个tutorial开始,首先尝试使用NDK构建一个非常简单的C项目,编译,并看到你能够在Android设备上运行.
那时事情会变得更加清晰.
掌握了这一点之后,我建议你开始将代码小部分移动到该项目,同时用存根替换OpenCV函数,并让代码在Android上编译和运行(什么都不做).
在那之后,阅读有关将OpenCV依赖性集成到NDK项目中的信息,这并不难(至少在我的情况下不是这样).
这个step-by-step对我来说非常有用.
至于你是否可以“自动”将你的(可能是视觉工作室)项目文件翻译成Android NDK制作文件的问题 – 答案通常是否定的.有些工具声称可以做到这一点,但我从来没有成功过任何一种工具.
MediaCodec如何在Android框架内找到编解码器?
我在android内部的知识非常有限.
这是我的发现:
有一个xml文件代表android系统中的编解码器细节.
device/tI/Omap3evm/media_codecs.xml for an example.
这意味着,如果我们使用Media Codec从Java Application创建编解码器
MediaCodec codec = MediaCodec.createDecoderByType(type);
应该在xml文件的帮助下找出相应的编码器.
我在做什么?
我试图找出代码的哪一部分正在读取xml并根据给定的’type’找到编解码器.
1)应用层:
MediaCodec codec = MediaCodec.createDecoderByType(type);
2)MediaCodec.java – > [frameworks / base / media / java / android / media / MediaCodec.java]
public static MediaCodec createDecoderByType(String type) { return new MediaCodec(type,true /* nameIsType */,false /* encoder */); }
3)
private MediaCodec( String name,boolean nameIsType,boolean encoder) { native_setup(name,nameIsType,encoder); --> JNI Call. }
4)
JNI实施 – > [frameworks / base / media / jni / android_media_MediaCodec.cpp]
static void android_media_MediaCodec_native_setup (..) { ....... const char *tmp = env->GetStringUTFChars(name,NULL); sp<JMediaCodec> codec = new JMediaCodec(env,thiz,tmp,encoder); ---> Here }
来自frameworks / base / media / jni / android_media_MediaCodec.cpp
JMediaCodec::JMediaCodec( ..) { .... mCodec = MediaCodec::CreateByType(mLooper,name,encoder); //Call goes to libstagefright .... } sp<MediaCodec> MediaCodec::CreateByType( const sp<ALooper> &looper,const char *mime,bool encoder) { sp<MediaCodec> codec = new MediaCodec(looper); if (codec->init(mime,encoder) != OK) { --> HERE. return NULL; } return codec; } status_t MediaCodec::init(const char *name,bool nameIsType,bool encoder) { // MediaCodec }
我很震惊这个流程.如果有人指出如何推进它将会有很大帮助.
谢谢.
解决方法
> MediaCodec :: CreateByType将创建一个新的MediaCodec对象
> MediaCodec构造函数将创建一个新的ACodec对象并将其存储为mCodec
>当调用MediaCodec :: init时,它会在内部指示底层ACodec通过mCodec->initiateAllocateComponent
分配OMX组件.
> ACodec :: initiateallocateComponent将调用onAllocateComponent
> ACodec :: UninitializedState :: onAllocateComponent将调用OMXCodec :: findMatchingCodecs来查找与从调用者传递的MIME类型匹配的编解码器.
>在OMXCodec :: findMatchingCodecs中,有一个调用将MediaCodecList的实例检索为MediaCodecList::getInstance()
.
>在MediaCodecList :: getInstance中,检查是否存在现有的MediaCodecList,否则为a new object of MediaCodecList
is created.
>在MediaCodecList的构造函数中,调用parseXMLFile
,文件名为/etc/media_codecs.xml.
> parseXMLFile读取内容并将不同的组件名称等存储到MediaCodecList中,MediaCodecList也可用于任何其他编解码器实例.用于解析的辅助函数是startElementHandler
.感兴趣的功能可以是addMediaCodec
.
通过这些步骤,XML文件内容被翻译成可由任何其他模块使用的列表. MediaCodecList也在Java层公开,可以从here引用.
我已经跳过了一些跳,其中MediaCodec和ACodec使用消息来实际通信和调用方法,但是所提供的流程应该对底层机制有一个很好的了解.
今天关于如何在未找到编解码器的Windows计算机上使用opencv和找不到所需的编解码器的讲解已经结束,谢谢您的阅读,如果想了解更多关于C#编写的windows计算器的实例代码、FFMPEG - 在流 #0 中找不到编解码器 pcm_s16le 的标签,容器当前不支持编解码器、java – 在计算机上将C opencv项目转换为opencv android的步骤、MediaCodec如何在Android框架内找到编解码器?的相关知识,请在本站搜索。
本文标签: