简体   繁体   English

如何获得文字的颜色?

[英]How do I get the color of the text?

I've been using the Microsoft OCR API and I'm getting the text from the images but I would like to know if the text is in an specific color or has an specific background color. 我一直在使用Microsoft OCR API,并且从图像中获取文本,但是我想知道文本是特定颜色还是特定背景颜色。

For example I have the following image and I would like to know if there is text in red ie image 例如我有以下图像,我想知道是否有红色文字, 即图像

I thought that this line: 我以为这行:

 string requestParameters = "language=unk&detectOrientation=true";

would help me to establish the parameters I'd like to recieve from the image so if I wanted to know the color in a line of words. 可以帮助我建立想要从图像中接收的参数,因此如果我想用一行文字来了解颜色。 So I added a visual feature like this: 所以我添加了这样的视觉功能:

 string requestParameters = "visualFeatures=Color,language=unk&detectOrientation=true";

But this did not solve the problem. 但这并没有解决问题。

Also: Can I mix the uriBase link from the image analysis and the one from the OCR? 另外:我可以混合使用图像分析中的uriBase链接和OCR中的一个吗?

There is currently no way to retrieve the color information and OCR results in a single call. 当前无法通过单个调用来检索颜色信息和OCR结果。

You could try using the bounding boxes returned from OCR to crop the original image, and then send the crop it to the analyze endpoint with visualFeatures=color to get the color information for the detected text. 您可以尝试使用OCR返回的边界框来裁剪原始图像,然后使用visualFeatures = color将其发送到分析端点以获取检测到的文本的颜色信息。

According to documentation , the possible request parameters of this api are: 根据文档 ,此api的可能请求参数为:

language, detectOrientation 语言,detectOrientation

and the returned metadata has these entities: 返回的元数据具有以下实体:

orientation, language, regions, lines, words, boundingBox, text 方向,语言,区域,线条,单词,boundingBox,文本

It will be possible to combine the OCR algorithm with another one of the computer vision algorithms to detect the dominating colors in the text regions that the OCR identified. 可以将OCR算法与另一种计算机视觉算法结合使用,以检测OCR识别的文本区域中的主要颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM