本文整理汇总了C#中Scalar类的典型用法代码示例。如果您正苦于以下问题:C# Scalar类的具体用法?C# Scalar怎么用?C# Scalar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Scalar类属于命名空间,在下文中一共展示了Scalar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
var gray = new Mat(FilePath.Image.Lenna, ImreadModes.GrayScale);
var dst = new Mat(FilePath.Image.Lenna, ImreadModes.Color);
BRISK brisk = BRISK.Create();
KeyPoint[] keypoints = brisk.Detect(gray);
if (keypoints != null)
{
var color = new Scalar(0, 255, 0);
foreach (KeyPoint kpt in keypoints)
{
float r = kpt.Size / 2;
Cv2.Circle(dst, kpt.Pt, (int)r, color);
Cv2.Line(dst,
new Point2f(kpt.Pt.X + r, kpt.Pt.Y + r),
new Point2f(kpt.Pt.X - r, kpt.Pt.Y - r),
color);
Cv2.Line(dst,
new Point2f(kpt.Pt.X - r, kpt.Pt.Y + r),
new Point2f(kpt.Pt.X + r, kpt.Pt.Y - r),
color);
}
}
using (new Window("BRISK features", dst))
{
Cv2.WaitKey();
}
}
开发者ID:JiphuTzu,项目名称:opencvsharp,代码行数:31,代码来源:BRISKSample.cs
示例2: GetValueToEncode
public override ScalarValue GetValueToEncode(ScalarValue value, ScalarValue priorValue, Scalar field)
{
if (value == null)
return ScalarValue.Null;
return value;
}
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:7,代码来源:NoneOperatorCodec.cs
示例3: Update
// Update is called once per frame
void Update () {
cap.Read (frame);
if (!frame.Empty()){
//assume this part of the frame contains only background
smoothed_img = frame.Blur(new Size(5,5));
frame_hsv = frame.CvtColor (ColorConversionCodes.BGR2HSV);
Scalar lb = new Scalar (0, 0, 50);
Scalar ub = new Scalar (180, 70, 180);
Mat disc = Cv2.GetStructuringElement (MorphShapes.Ellipse, new Size (7, 7));
Cv2.MorphologyEx (thresh, thresh, MorphTypes.Close, disc,null,3);
contours = Cv2.FindContoursAsMat (thresh , RetrievalModes.List, ContourApproximationModes.ApproxSimple);
mask = new Mat (thresh.Size (), thresh.Type (), Scalar.All (0));
Cv2.Merge(new Mat[]{mask,mask,mask},mask);
Cv2.BitwiseAnd (mask, frame, mask);
//Cv2.Merge(new Mat[]{frame_backproj,frame_backproj,frame_backproj},frame_backproj);
tex.LoadImage (smoothed_img.ToBytes (".png", new int[]{ 0 }));
}
}
开发者ID:orlitany,项目名称:coffeeUnderTheSea,代码行数:36,代码来源:segment_simple.cs
示例4: GetValueToEncode
public override ScalarValue GetValueToEncode(ScalarValue value_Renamed, ScalarValue priorValue, Scalar field)
{
if (priorValue == null)
{
return value_Renamed;
}
if (value_Renamed == null)
{
if (field.Optional)
{
if (priorValue == ScalarValue.UNDEFINED && field.DefaultValue.Undefined)
{
return null;
}
return ScalarValue.NULL;
}
throw new ArgumentException();
}
if (priorValue.Undefined)
{
if (value_Renamed.Equals(field.DefaultValue))
{
return null;
}
return value_Renamed;
}
if (!value_Renamed.Equals(((NumericValue) priorValue).Increment()))
{
return value_Renamed;
}
return null;
}
开发者ID:marlonbomfim,项目名称:openfastdotnet,代码行数:32,代码来源:IncrementIntegerOperatorCodec.cs
示例5: DecodeEmptyValue
public override ScalarValue DecodeEmptyValue(ScalarValue priorValue, Scalar field)
{
if (!field.IsOptional)
return field.DefaultValue;
return null;
}
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:7,代码来源:ConstantOperatorCodec.cs
示例6: Run
public void Run()
{
var dst = new Mat(FilePath.Lenna, LoadMode.Color);
var gray = new Mat(FilePath.Lenna, LoadMode.GrayScale);
StarDetector detector = new StarDetector(45);
KeyPoint[] keypoints = detector.Run(gray);
if (keypoints != null)
{
var color = new Scalar(0, 255, 0);
foreach (KeyPoint kpt in keypoints)
{
float r = kpt.Size / 2;
Cv2.Circle(dst, kpt.Pt, (int)r, color, 1, LineType.Link8, 0);
Cv2.Line(dst,
new Point2f(kpt.Pt.X + r, kpt.Pt.Y + r),
new Point2f(kpt.Pt.X - r, kpt.Pt.Y - r),
color, 1, LineType.Link8, 0);
Cv2.Line(dst,
new Point2f(kpt.Pt.X - r, kpt.Pt.Y + r),
new Point2f(kpt.Pt.X + r, kpt.Pt.Y - r),
color, 1, LineType.Link8, 0);
}
}
using (new Window("StarDetector features", dst))
{
Cv.WaitKey();
}
}
开发者ID:healtech,项目名称:opencvsharp,代码行数:31,代码来源:StarDetectorSample.cs
示例7: RaiseArmTrigger
public RaiseArmTrigger(XmlNode node)
{
mHeightThreshold = Nui.magnitude(Nui.joint(Nui.Shoulder_Centre) - Nui.joint(Nui.Hip_Centre));
mAngleThreshold = Scalar.Create(.48f);
mDepthThreshold = Scalar.Create(GetFloat(node, 3.6f, "DepthThreshold"));
mWidthThreshold = Scalar.Create(GetFloat(node, 1f, "WidthThreshold"));
mBody = Nui.joint(Nui.Hip_Centre);
Condition inWidth = Nui.abs(Nui.x(Nui.joint(Nui.Hip_Centre))) < mWidthThreshold;
Condition inDepth = Nui.z(Nui.joint(Nui.Hip_Centre)) < mDepthThreshold;
Condition inRange = C.And(inWidth, inDepth);
Vector up = Vector.Create(0f, 1f, 0f);
mArmR = Nui.joint(Nui.Hand_Right) - Nui.joint(Nui.Shoulder_Right);
mArmL = Nui.joint(Nui.Hand_Left) - Nui.joint(Nui.Shoulder_Left);
mAngleR = Nui.dot(up, mArmR);
mAngleL = Nui.dot(up, mArmL);
mTriggerR = C.And(Nui.y(mArmR) > mHeightThreshold, mAngleR > mAngleThreshold);
mTriggerL = C.And(Nui.y(mArmL) > mHeightThreshold, mAngleL > mAngleThreshold);
mTrigger = C.And(C.Or(mTriggerR, mTriggerL), inRange);
mTrigger.OnChange += new ChangeDelegate(mTrigger_OnChange);
}
开发者ID:JohnMcCaffery,项目名称:ChimeraClean,代码行数:25,代码来源:RaiseArmTrigger.cs
示例8: DecodeValue
public override ScalarValue DecodeValue(ScalarValue val, ScalarValue priorVal, Scalar field)
{
if (priorVal == null)
{
Global.HandleError(Error.FastConstants.D6_MNDTRY_FIELD_NOT_PRESENT, "The field " + field + " must have a priorValue defined.");
return null;
}
if (val == null)
{
return null;
}
DecimalValue priorValue;
if (priorVal.Undefined)
{
if (field.DefaultValue.Undefined)
{
priorValue = (DecimalValue) field.BaseValue;
}
else
{
priorValue = (DecimalValue) field.DefaultValue;
}
}
else
{
priorValue = (DecimalValue) priorVal;
}
var value_Renamed = (DecimalValue) val;
return new DecimalValue(value_Renamed.mantissa + priorValue.mantissa, value_Renamed.exponent + priorValue.exponent);
}
开发者ID:marlonbomfim,项目名称:openfastdotnet,代码行数:35,代码来源:DeltaDecimalOperatorCodec.cs
示例9: Parse
public override Field Parse(System.Xml.XmlElement fieldNode, bool optional, ParsingContext context)
{
Operator.Operator operator_Renamed = Operator.Operator.NONE;
string defaultValue = null;
string key = null;
string ns = "";
System.Xml.XmlElement operatorElement = GetOperatorElement(fieldNode);
if (operatorElement != null)
{
if (operatorElement.HasAttribute("value"))
defaultValue = operatorElement.GetAttribute("value");
operator_Renamed = Operator.Operator.GetOperator(operatorElement.Name);
if (operatorElement.HasAttribute("key"))
key = operatorElement.GetAttribute("key");
if (operatorElement.HasAttribute("ns"))
ns = operatorElement.GetAttribute("ns");
if (operatorElement.HasAttribute("dictionary"))
context.Dictionary = operatorElement.GetAttribute("dictionary");
}
FASTType type = GetType(fieldNode, context);
var scalar = new Scalar(GetName(fieldNode, context), type, operator_Renamed, type.GetValue(defaultValue), optional);
if (fieldNode.HasAttribute("id"))
scalar.Id = fieldNode.GetAttribute("id");
if (key != null)
scalar.Key = new QName(key, ns);
scalar.Dictionary = context.Dictionary;
ParseExternalAttributes(fieldNode, scalar);
return scalar;
}
开发者ID:marlonbomfim,项目名称:openfastdotnet,代码行数:29,代码来源:ScalarParser.cs
示例10: setHsvColor
public void setHsvColor (Scalar hsvColor)
{
double minH = (hsvColor.val [0] >= mColorRadius.val [0]) ? hsvColor.val [0] - mColorRadius.val [0] : 0;
double maxH = (hsvColor.val [0] + mColorRadius.val [0] <= 255) ? hsvColor.val [0] + mColorRadius.val [0] : 255;
mLowerBound.val [0] = minH;
mUpperBound.val [0] = maxH;
mLowerBound.val [1] = hsvColor.val [1] - mColorRadius.val [1];
mUpperBound.val [1] = hsvColor.val [1] + mColorRadius.val [1];
mLowerBound.val [2] = hsvColor.val [2] - mColorRadius.val [2];
mUpperBound.val [2] = hsvColor.val [2] + mColorRadius.val [2];
mLowerBound.val [3] = 0;
mUpperBound.val [3] = 255;
Mat spectrumHsv = new Mat (1, (int)(maxH - minH), CvType.CV_8UC3);
for (int j = 0; j < maxH-minH; j++) {
byte[] tmp = {(byte)(minH + j), (byte)255, (byte)255};
spectrumHsv.put (0, j, tmp);
}
Imgproc.cvtColor (spectrumHsv, mSpectrum, Imgproc.COLOR_HSV2RGB_FULL, 4);
}
开发者ID:lsewata,项目名称:OpenCVForUnity,代码行数:26,代码来源:ColorBlobDetector.cs
示例11: DecodeValue
public override ScalarValue DecodeValue(ScalarValue newValue, ScalarValue priorValue, Scalar field)
{
if (priorValue == null && !field.IsOptional)
{
Global.ErrorHandler.OnError(null, DynError.MandatoryFieldNotPresent, "");
return null;
}
var baseValue = (StringValue) (priorValue == null || priorValue.IsUndefined
? field.BaseValue
: priorValue);
if (newValue == null || newValue.IsNull)
{
if (!field.IsOptional)
throw new ArgumentException("");
return null;
}
string delta = ((StringValue) newValue).Value;
int length = Math.Max(baseValue.Value.Length - delta.Length, 0);
string root = baseValue.Value.Substring(0, (length) - (0));
return new StringValue(root + delta);
}
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:26,代码来源:TailOperatorCodec.cs
示例12: DecodeEmptyValue
public override ScalarValue DecodeEmptyValue(ScalarValue previousValue, Scalar field)
{
if (!field.Optional)
{
return field.DefaultValue;
}
return null;
}
开发者ID:marlonbomfim,项目名称:openfastdotnet,代码行数:8,代码来源:ConstantOperatorCodec.cs
示例13: GetLEDPositinon
//LEDの位置検出
public Microsoft.Kinect.CameraSpacePoint GetLEDPositinon(int imgW, int imgH, byte[] colors, Scalar color, ushort[] depthBuffer)
{
//二値化 → 輪郭抽出・中心位置取得 → depth位置に変換 → 座標取得
//Mat ColorImage = this.CreatMat(colors, imgW, imgH);
//Mat GrayScaleImage = this.Converter(ColorImage);
Mat GrayScaleImage = this.Converter(colors, imgW, imgH, 4);
Point pt = this.GetCenterPointofLED(GrayScaleImage);
return this.GetCenterPosition(pt, depthBuffer, imgW, imgH);
}
开发者ID:tomokitejika,项目名称:ShadowMediaSystem,代码行数:10,代码来源:Calibration.cs
示例14: GetValueToEncode
public override ScalarValue GetValueToEncode(ScalarValue value_Renamed, ScalarValue priorValue, Scalar field)
{
if (value_Renamed == null)
{
return field.DefaultValue.Undefined ? null : ScalarValue.NULL;
}
return value_Renamed.Equals(field.DefaultValue)?null:value_Renamed;
}
开发者ID:marlonbomfim,项目名称:openfastdotnet,代码行数:9,代码来源:DefaultOperatorCodec.cs
示例15: GetValueToEncode
public override ScalarValue GetValueToEncode(ScalarValue value_Renamed, ScalarValue priorValue, Scalar field)
{
if (value_Renamed == null)
{
return ScalarValue.NULL;
}
return value_Renamed;
}
开发者ID:marlonbomfim,项目名称:openfastdotnet,代码行数:9,代码来源:NoneOperatorCodec.cs
示例16: GetInitialValue
protected override ScalarValue GetInitialValue(Scalar field)
{
if (!field.DefaultValue.IsUndefined)
return field.DefaultValue;
if (field.IsOptional)
return null;
Global.ErrorHandler.OnError(null, DynError.NoDefaultValue, "No default value for {0}", field);
return null;
}
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:12,代码来源:CopyOperatorCodec.cs
示例17: DecodeEmptyValue
public override ScalarValue DecodeEmptyValue(ScalarValue priorValue, Scalar field)
{
ScalarValue value = priorValue;
if (value != null && value.IsUndefined)
value = (field.DefaultValue.IsUndefined) ? null : field.DefaultValue;
if (value == null && !field.IsOptional)
{
Global.ErrorHandler.OnError(null, DynError.MandatoryFieldNotPresent, "The field {0} was not present.",
field);
}
return value;
}
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:12,代码来源:TailOperatorCodec.cs
示例18: TestScalar
public void TestScalar()
{
var a = new Scalar(2);
var b = a.Pow(new Scalar(3));
Assert.True(b.Value == 8);
var c = new Scalar(1);
var d = c.Log();
Assert.True(d.Value == 0);
}
开发者ID:bvssvni,项目名称:csharp-mathilda,代码行数:12,代码来源:TestPower.cs
示例19: CopyMakeBorder
/// <summary>
/// Forms a border around the image
/// </summary>
/// <param name="src">The source image</param>
/// <param name="dst">The destination image; will have the same type as src and
/// the size Size(src.cols+left+right, src.rows+top+bottom)</param>
/// <param name="top">Specify how much pixels in each direction from the source image rectangle one needs to extrapolate</param>
/// <param name="bottom">Specify how much pixels in each direction from the source image rectangle one needs to extrapolate</param>
/// <param name="left">Specify how much pixels in each direction from the source image rectangle one needs to extrapolate</param>
/// <param name="right">Specify how much pixels in each direction from the source image rectangle one needs to extrapolate</param>
/// <param name="borderType">The border type</param>
/// <param name="value">The border value if borderType == Constant</param>
public static void CopyMakeBorder(InputArray src, OutputArray dst, int top, int bottom, int left, int right, BorderType borderType, Scalar? value = null)
{
if (src == null)
throw new ArgumentNullException("src");
if (dst == null)
throw new ArgumentNullException("dst");
src.ThrowIfDisposed();
dst.ThrowIfNotReady();
Scalar value0 = value.GetValueOrDefault(new Scalar());
NativeMethods.imgproc_copyMakeBorder(src.CvPtr, dst.CvPtr, top, bottom, left, right, (int)borderType, value0);
dst.Fix();
}
开发者ID:josephgodwinkimani,项目名称:opencvsharp,代码行数:24,代码来源:Cv2_imgproc.cs
示例20: KinectScaledAxis
public KinectScaledAxis(string name, AxisBinding binding)
: base(name, new ScalarUpdater(sAnchor * MakeDZ()), new ScalarUpdater(sAnchor * MakeScale()), binding)
{
mDeadzoneScale = sTmpDZScale;
mScaleScale = sTmpSScale;
mDeadzoneScale.Value = G.Cfg.GetDeadzone(name);
mScaleScale.Value = G.Cfg.GetScale(name);
Scale.ManuallyChanged += new Action<float>(Scale_ManuallyChanged);
Deadzone.ManuallyChanged += new Action<float>(Deadzone_ManuallyChanged);
}
开发者ID:JohnMcCaffery,项目名称:ChimeraClean,代码行数:12,代码来源:KinectScaledAxis.cs
注:本文中的Scalar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论