我到处都看,但似乎没有一个标准(我可以看到)如何检查图像是否为空白.在C#中
我有办法做到这一点,但很想知道检查图像是否为空白的正确方法是什么,所以每个人都可以在将来知道.
我不会复制粘贴一堆代码,如果你想要我,这将是我的荣幸,但我首先要解释我如何检查图像是否为空白.
你拍一张.jpg图片,获取它的宽度.例如500像素然后你将它除以2给你250
然后你检查每个像素的颜色在(250宽度和高度)的位置(你迭代的地方是想象图像的高度).
这样做只是垂直检查图像的中间像素线.它通过所有像素检查,看看颜色是否是白色除外.我已经这样做了,所以你不必搜索所有500*像素的高度,因为你几乎总是会遇到页面中间的颜色.
它的工作......有点慢......必须有更好的方法来做到这一点?您可以将其更改为垂直搜索2/3/4行,以增加发现非空白页面的机会,但这将花费更长时间.
(另请注意,使用图像的大小来检查它是否包含某些内容在这种情况下不起作用,因为打开两个句子的页面和空白页面的大小彼此太靠近)
添加解决方案后.
帮助实施和理解解决方案的资源.
(请注意,在第一个网站上,所声明的Pizelformat实际上是Pixelformat) - 我知道的小错误,只是提到,可能会引起一些混淆.
在我实施该方法以加速像素搜寻之后,速度没有增加那么多.所以我认为我做错了什么.
40个图像的旧时间= 15.63.
40张图片的新时间= 15.43
我看到DocMax 引用的伟大文章,代码"锁定"在一组像素中.(或者多数民众赞成我是如何理解的)所以我所做的就是锁定每页的像素中间行.这是正确的举动吗?
private int testPixels(String sourceDir)
{
//iterate through images
string[] fileEntries = Directory.GetFiles(sourceDir).Where(x => x.Contains("JPG")).ToArray();
var q = from string x in Directory.GetFiles(sourceDir)
where x.ToLower().EndsWith(".jpg")
select new FileInfo(x);
int holder = 1;
foreach (var z in q)
{
Bitmap mybm= Bitmap.FromFile(z.FullName) as Bitmap;
int blank = getPixelData2(mybm);
if (blank == 0)
{
holder …Run Code Online (Sandbox Code Playgroud) 下面的代码会报错,为什么呢?
超出导航超时:超出 60000ms
我使用的是 puppeteer 版本 1.19.0
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setCacheEnabled(false);
try {
const response = await page.goto("https://www.gatsbyjs.com", {
waitUntil: "networkidle0",
timeout: 60000
});
console.log("Status code:", response.status());
} catch (error) {
console.log(error.message);
}
await browser.close();
})();
Run Code Online (Sandbox Code Playgroud)
其他一些 URL 工作正常,所以我想知道这个特定 URL 是否有什么特别之处?
我尝试了解 Kubernetes 中的 hostIP 和 hostPort。
这是我的集群配置:
3个流浪节点:
nodes = [
{ :hostname => 'k8s-master', :ip => '192.168.150.200', :ram => 4096 },
{ :hostname => 'k8s-minion1', :ip => '192.168.150.201', :ram => 4096 },
{ :hostname => 'k8s-minion2', :ip => '192.168.150.202', :ram => 4096 },
]
Run Code Online (Sandbox Code Playgroud)
我编写以下清单来测试它:
apiVersion: v1
kind: Pod
metadata:
name: firstpod
spec:
containers:
- name: container
image: nginx
ports:
- containerPort: 80
hostIP: 10.0.0.1
hostPort: 8080
Run Code Online (Sandbox Code Playgroud)
我部署的是kubectl apply -f port.yml
pod 在 k8s-minion2 上运行
kubectl get pods …Run Code Online (Sandbox Code Playgroud) Microsoft发布安全通报(2269637)不安全的库加载可能允许远程执行代码.
该注释指的是有助于检测此问题的工具和动态链接库安全性的编程指南.
这些指南如何转换为.NET开发?我认为这只影响平台调用.
这仍然是导入系统库的推荐方法吗?
DllImport("user32.dll")]
Run Code Online (Sandbox Code Playgroud) 我正在使用身份转换,在此期间,我需要使用XSLT更改节点的位置.假设,我有一个像这样的XML:
<root>
<a>
<b1>SampleB1</b1>
<b2>
<c1>zyx</c1>
<c2>wvu</c2>
<c3>tsr</c3>
<c4>dtg</c4>
<c5>hkj</c5>
</b2>
<b3>SampleB3</b3>
</a>
</root>
Run Code Online (Sandbox Code Playgroud)
然后我想改变节点'c4'和'c5'的位置,并希望输出为:
<root>
<c4>dtg</c4>
<c5>hkj</c5>
<a>
<b1>SampleB1</b1>
<b2>
<c1>zyx</c1>
<c2>wvu</c2>
<c3>tsr</c3>
</b2>
<b3>SampleB3</b3>
</a>
</root>
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我,我们怎么做到这一点.
谢谢 !!!
更新:我开始怀疑这是否是由于一个错误:
https://github.com/domaindrivendev/Swashbuckle/issues/590
但是解决方法表明似乎没有解决我的问题.
我正在使用Swashbuckle为C#ASP.NET Web API项目生成API文档.
我的目标是允许以下作为有效的URL:
/endpoint/items/123/foo?param2=bar
Run Code Online (Sandbox Code Playgroud)
将所需参数(param1)设置为"foo",将可选参数(param2)设置为"bar".我希望两个参数都包含在一个C#参数对象中.(使用其他可选参数,如param3等).几个端点将使用相同的参数,我希望有一个表示参数的对象.
Swagger/Swashbuckle的细节大多是黑盒子,我无法弄明白.我在参数列表中得到了重复项.
重现问题的示例代码:
// This endpoint is generating documentation the way I would like.
[HttpGet]
[Route("endpoint1/items/{id}/{param1}")]
public string GetDataForParameters(int id, string param1, string param2 = null, string param3 = null)
{
return string.Format("Params: {1}, {2}, {3}", id, param1, param2, param3);
}
// This endpoint has the structure I would like, but I get duplicates for param1 in the documentation.
[HttpGet]
[Route("endpoint2/items/{id}/{param1}")]
public string GetDataForParameters(int id, [FromUri(Name = "")]MyParams myParams)
{
return string.Format("Params: …Run Code Online (Sandbox Code Playgroud) 我有一个 Angular 项目,我想使用Application Insights进行日志记录。
我试过这个教程,它工作得很好,但不是在 SSR 模式下。
当我在 SSR 模式下运行应用程序时,我收到此错误:
RerefenceError: XmlHttpRequest is not defined
Run Code Online (Sandbox Code Playgroud)
我找到了这个SO post,这似乎与我的问题相同。按照它的一个答案,我已经安装了XMLHttpRequest库并将这一行添加到server.ts:
(global as any).XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
Run Code Online (Sandbox Code Playgroud)
不为我工作。Angular Universal 尚未响应http 请求。另外,我尝试使用“xhr2”库而不是“xmlhttprequest”,它也不起作用。
如何获得应用程序洞察以在 Angular SSR 模式下工作?
这就是我将应用程序洞察添加到我的项目的方式。
monitoring.service.ts:aiAPI的包装器:
RerefenceError: XmlHttpRequest is not defined
Run Code Online (Sandbox Code Playgroud)
然后像这样调用aiat的初始化代码app.component.ts:
(global as any).XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
Run Code Online (Sandbox Code Playgroud)
我把它通过周围的所有相关应用的见解API的方法调用,如工作trackException()和this.appInsights.loadAppInsights()一个if statememt内:
import { ApplicationInsights } from "@microsoft/applicationinsights-web";
class MonitoringService …Run Code Online (Sandbox Code Playgroud) azure-application-insights server-side-rendering angular-universal angular
这是我的情况。
我正在使用 EPiServer 9 并且我已经配置了一个 SqlServerMembershipProvider 如下:
<add name="SqlServerMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
connectionStringName="EPiServerXYZ"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="8"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
applicationName="/"
passwordStrengthRegularExpression="^.*(?=.{8,})(?=.*\d)(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[^\w\d\s]).*$" />
Run Code Online (Sandbox Code Playgroud)
一切正常,验证和不同的场景。
我们的问题是会员提供者显示的错误消息是通过使用配置创建的,它最终给出了用户不友好的消息,例如:
我很想设置一个自定义错误消息,它真正向用户解释了我们在用于验证密码的正则表达式中的所有要求。
到目前为止,我可以考虑这样做的唯一方法是实现/扩展我们正在使用的当前提供程序,以便在验证出现问题时设置自定义错误消息,但我想可能有另一种更好/更简单的方法来做到这一点.
提前致谢!
我们有一个更新程序,可以自动将 WebDeploy 包发布到 IIS 服务器。该程序适用于 MVC 5 - 应用程序,但不适用于 .Net Core 应用程序。我们使用 Microsoft.Web.Deployment - API,我的发布方法如下所示:
private void UpdateIIS(DTOs.ApplicationConfiguration.ApplicationServer applicationServer, DTOs.Update.Update update) {
// SSL-Zertifikatsfehler ignorieren
System.Net.ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(
(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => { return true; });
var sourceBaseOptions = new DeploymentBaseOptions();
var destBaseOptions = new DeploymentBaseOptions() {
ComputerName = string.Format("https://{0}:{1}/msdeploy.axd?site={2}", applicationServer.Adresse, applicationServer.MSDeployPort, applicationServer.SiteName),
UserName = applicationServer.User,
Password = applicationServer.Passwort,
AuthenticationType = "Basic"
};
string updatePackage = Directory.GetFiles(update.UpdateDirectory, "*.zip").FirstOrDefault();
if (!File.Exists(updatePackage)) {
throw new Exception("Update-Paketdatei …Run Code Online (Sandbox Code Playgroud) 我刚刚将项目从 ASP.Net 4.5 迁移到 ASP.Net Core。我有一个 REST API get,过去用于返回 blob,但现在返回 JSON。
这是旧代码:
[HttpGet]
[ResponseType(typeof(HttpResponseMessage))]
[Route("Download/{documentId}")]
public async Task<HttpResponseMessage> DownloadDocument(string documentId)
{
try
{
var result = await TheDocumentService.DownloadDocument(documentId);
return result;
}
catch (Exception ex)
{
return new HttpResponseMessage
{
StatusCode = HttpStatusCode.InternalServerError,
Content = new StringContent(ex.Message)
};
}
}
Run Code Online (Sandbox Code Playgroud)
ASP.net Core 中的代码除了[ResponseType(typeof(HttpResponseMessage))]在 ASP.Net Core 中不起作用之外是相同的,并且两种解决方案的返回结果也相同。
但是当在客户端查看服务器的响应时,它们是不同的。
因此,它们之间唯一的区别是[ResponseType(typeof(HttpResponseMessage))]. ASP.NET Core 中有类似的东西吗?
asp.net ×3
c# ×3
.net ×2
asp.net-core ×2
security ×2
angular ×1
asp.net-mvc ×1
dll ×1
episerver ×1
iis ×1
image ×1
kubernetes ×1
loadlibrary ×1
msdeploy ×1
node.js ×1
pinvoke ×1
pixel ×1
port ×1
puppeteer ×1
serverless ×1
swagger ×1
swashbuckle ×1
webdeploy ×1
xslt ×1