小编Ste*_*e K的帖子

需要帮助算法通过锯齿状数组解析索引

哎呀!我知道我最终会得到这个,但是在这一点上,我差不多2个小时,仍然卡住了.

我需要为特定位置的锯齿状数组的每个"级别"解析各个索引.这很难解释,但如果你想象一个长度为[2,3,4]的3级锯齿状阵列.如果你然后把它变成一个单独的数组,它的大小就是24.现在,假设你需要找到等于单个数组索引的索引(每个级别的锯齿状数组一个). 22.这将是1,2,1.找出单个场景并不难,但我想弄清楚算法是为了解决变深度锯齿状阵列的这些值.

这是我当前尝试的简单代码示例:

using System;

class Program
{
    static void Main(string[] args)
    {
        //  Build up the data and info about level depth
        int[] levelDepth = new[] { 2, 3, 4 };
        int[][][] data = new int[][][]
        {
            new int[][] { new int[4], new int[4], new int[4] },
            new int[][] { new int[4], new int[4], new int[4] }
        };

        int requestedValue = 22;
        float temp = requestedValue;

        //  Store the index of each level array to get to the …
Run Code Online (Sandbox Code Playgroud)

c# algorithm

5
推荐指数
1
解决办法
261
查看次数

Can't make IAMStreamConfig.SetFormat() to work with LifeCam Studio

I'm brand new to DirectShow and am working on adding a video stream to my application. I've looked into many solutions out there (TouchLess, DirectShow.net, etc.) and ended up going with this small project on Code Project There isn't much to it, which is why I selected it; I wanted a small code base to work with, as I need to get this feature implemented quickly.

经过一整天的阅读,实验和调试,我终于让一切都运转良好.有一个延迟,这是一个无赖,但我可以稍后担心.我现在的问题是相机能够1280X720,我想使用这个分辨率.然而,似乎决定以640x480捕获.当我越来越深入地学习如何设置分辨率时,我终于认为我已经弄明白了.我还在我用作基础的评论中的代码项目页面上找到了代码.

经过6个小时的尝试,我无法让这台相机改变它的分辨率.我没有收到任何错误,从SetFormat()返回的HRESULT为0,但相机不会改变分辨率.

粘贴所有东西的代码太多了,但是我希望包含构建图形的部分,因为我认为这就是问题所在.

以下是设置图表的代码

void CameraMethods::StartCamera(int camIndex, interior_ptr<int> width, 
    interior_ptr<int> height)
{ …
Run Code Online (Sandbox Code Playgroud)

directshow directshow.net

5
推荐指数
1
解决办法
9119
查看次数

均匀性如何表达?

我对统计数据一无所知,我很难找到一种描述我的问题的方法.

我正在对一个能测量导体电流均匀性的系统进行一些初步研究.基本上我们需要测量信号在表面上展开的均匀程度.

我正在研究如何确定数据集的一致性,并且遇到了这个有希望的问题.但是我意识到我不知道用什么单位来表达一致性.例如,如果我在对象表面上以网格图案进行100次等间距测量,并想描述这些值的均匀程度,您会怎么说呢?

  • "98%制服?" - 那是什么意思?98%的是什么?
  • "信号非常均匀地分散" - 好吧,很棒......但必须有更具体或科学的方式来传达......如何"均匀"?该陈述的数字表示是什么?

统计和数学不是我的事,所以如果这看起来像一个愚蠢的问题,请温柔......

math statistics

4
推荐指数
1
解决办法
8981
查看次数

IIFE创建模式 - 但如何支持构造函数参数?

作为一个长期的经典继承OO程序员,我非常习惯使用构造函数并创建接受所需参数作为构造函数参数的对象.例如,发送与订单相关的警报的对象可能如下所示:

var orderNotifier = function(orderId, notifier, recipients)
{
    this.notifyApproved = function()
    { 
        // use the notifier object passed as ctor param to send notifications 
        // related to orderId to recipients 
    }
    this.notifySomeOtherEvent = function() { // use the ctor params again }
}

//  then use it like
var on = new orderNotifier(12345, new BasicNotifier(), someArrayOfEmails);
on.notifyApproved();
Run Code Online (Sandbox Code Playgroud)

这是一个人为的例子,但举例说明了(恕我直言)参数化构造函数的价值.特别:

  1. 在单个语句中将状态传递给对象
  2. 简化的方法签名
  3. 内部状态是隐藏的

认识到JavaScript中的构造函数创建模式不能很好地支持信息隐藏,我被立即调用函数表达式(IIFE)模式所吸引,其闭包和更强的访问控制.现在我遇到了这样一个事实:我不能使用IIFE模式传递对象构造参数,或者至少我不明白我是怎么做的.

我知道你可以将参数传递给匿名函数,如下所示:

(function(param){})(someVar);
Run Code Online (Sandbox Code Playgroud)

但这与显式创建新对象并将参数传递给构造函数不同.根据IIFE模式的本质,我不一定要将数据传递给对象.

我上面的IIFE版本就像:

var orderNotifier = (function()
{
    var privateHelperMethod = function() { return 'blahblahblah'; …
Run Code Online (Sandbox Code Playgroud)

javascript

4
推荐指数
1
解决办法
3326
查看次数

使用EncoderParams将MemoryBmp上的Image.Save()转换为TIFF - 如何?

我有一个应用程序,允许用户定义图像的区域并将该区域保存到文件.我遇到了一个我无法解决的障碍.我创建的用于绘制所选区域的位图卡在"MemoryBmp"的ImageFormat中,看起来这是为任何非文件加载的位图设置的ImageFormat.问题是我的Bitmap是在内存中创建的,我想将它保存为CCITT4双色调TIFF但是我得到了"GDI +中发生了一般错误"的异常.我非常有信心这是因为Image.RawFormat属性是可怕的MemoryBmp.

Image.Save()有一个带有ImageFormat参数的重载,当我使用它传递ImageFormat.Tiff它保存得很好,但我没有机会指定我的编码器参数.

我能想到的唯一可能的解决方法是使用Image.Save(Image,ImageFormat)保存到磁盘然后重新加载它(RawFormat现在将正确设置为ImageFormat.Tif)然后再次保存通过编码器设置.这只是愚蠢,必须有更好的方法.

这里有一段代码(这只是测试内容),如果我之前的描述不够清楚,应该让你知道我在做什么:

SizeF dpiScale = GetScreenToImageDPIRatio(loadedImage);
using (Bitmap image = new Bitmap(loadedImage,
    (int)(_cropBox.Width * dpiScale.Width),
    (int)(_cropBox.Height * dpiScale.Height)))
{
    image.SetResolution(loadedImage.HorizontalResolution, 
        loadedImage.VerticalResolution);

    using (Graphics g = Graphics.FromImage(image))
    {
        g.DrawImage(loadedImage, 0, 0, new Rectangle(
            (int)(_cropBox.Location.X * dpiScale.Width),
            (int)(_cropBox.Location.Y * dpiScale.Height),
            (int)(_cropBox.Width * dpiScale.Width),
            (int)(_cropBox.Height * dpiScale.Height)),
            GraphicsUnit.Pixel);
    }

    //  It's stuck as a MemoryBmp so none of these checks will work
    if (true || image.RawFormat.Equals(ImageFormat.Tiff))
    {
        ImageCodecInfo tiffCodecInfo = ImageUtils.GetEncoderInfo("image/tiff");
        EncoderParameters myEncoderParameters = new EncoderParameters(2);

        myEncoderParameters.Param[0] = new
            EncoderParameter(System.Drawing.Imaging.Encoder.Compression, …
Run Code Online (Sandbox Code Playgroud)

c# system.drawing gdi+ system.drawing.imaging

2
推荐指数
1
解决办法
6273
查看次数

Netsuite API 响应时间长

我尝试根据记录类型和索引获取记录。

请求: {"recordtype":"customer","gu_action":"get_all","size":1000,"index":0}

它的工作正常。但是 Api 需要 4-5 分钟来响应每个 api 调用。知道如何减少这个时间吗?

我的 Restlet 代码:

get_all 动作将调用 get_Allrecords 函数:

/********************** Get All records of Record type *******************************/

function get_Allrecords(datain) {
        var all_IDs = getAllIDs(datain);
        var len = all_IDs.length;
        var result = new Array();
        var results = new Array();
        var fields = datain.fields; 
        for (var i = 0; i < len; i++) {
                var required_result = {};
                try {
                       result[i] = **nlapiLoadRecord(all_IDs[i].getRecordType(), all_IDs[i].id);**
                       if(fields != undefined && fields.length > 0) {
                          for( var …
Run Code Online (Sandbox Code Playgroud)

netsuite suitescript

2
推荐指数
1
解决办法
1221
查看次数