AnswerOpenCV(1001-1007)一周佳作欣赏

外国不过十一,所以利用十一假期,看看他们都在干什么。
一、小白问题
http://answers.opencv.org/question/199987/contour-single-blob-with-multiple-object/

Contour Single blob with multiple object

Hi to everyone.

I'm developing an object shape identification application and struck up with separating close objects using contour, Since close objects are identified as single contour. Is there way to separate the objects?

Things I have tried:1. I have tried Image segmentation with distance transform and Watershed algorithm - It works for few images only2. I have tried to separate the objects manual using the distance between two points as mentioned in http://answers.opencv.org/question/71... - I struck up with choosing the points that will separate the object.

I have attached a sample contour for the reference.

image description

Please suggest any comments to separate the objects.

分析:这个问题其实在阈值处理之前就出现了,我们常见的想法是对图像进行预处理,比如HSV 分割,或者在阈值处理的时候想一些方法。


二、性能优化
http://answers.opencv.org/question/109754/optimizing-splitmerge-for-clahe/

Optimizing split/merge for clahe

I am trying to squeeze the last ms from a tracking loop. One of the time consuminig parts is doing adaptive contrast enhancement (clahe), which is a necessary part. The results are great, but I am wondering whether I could avoid some copying/splitting/merge or apply other optimizations.

Basically I do the following in tight loop:

cv::cvtColor(rgb, hsv, cv::COLOR_BGR2HSV);
 
std::vector<cv::Mat> hsvChannels;
 
cv::split(hsv, hsvChannels);
 
m_clahe->apply(hsvChannels[2], hsvChannels[2]); /* m_clahe constructed outside loop */
 
cv::merge(hsvChannels, hsvOut);
 
cv::cvtColor(hsvOut, rgbOut, cv::COLOR_HSV2BGR);

On the test machine, the above snippet takes about 8ms (on 1Mpix images), The actual clahe part takes only 1-2 ms.

1 answer

You can save quite a bit. First, get rid of the vector. Then, outside the loop, create a Mat for the V channel only.

Then use extractChannel and insertChannel to access the channel you're using. It only accesses the one channel, instead of all three like split does.

The reason you put the Mat outside the loop is to avoid reallocating it every pass through the loop. Right now you're allocating and deallocating three Mats every pass.

test code:

#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
 
using namespace std;
using namespace cv;
 
int main(){
 
TickMeter tm;
Ptr<CLAHE> clahe = createCLAHE();
    clahe->setClipLimit(4);
    vector <Mat> hsvChannels;
    Mat img, hsv1, hsv2, hsvChannels2, diff;
    img = imread("lena.jpg");
    cvtColor (img, hsv1, COLOR_BGR2HSV);
    cvtColor (img, hsv2, COLOR_BGR2HSV);
    tm.start();
for (int i = 0; i < 1000; i++)
{
        split(hsv2, hsvChannels);
        clahe->apply(hsvChannels[2], hsvChannels[2]);
        merge(hsvChannels, hsv2);
}
    tm.stop();
    cout<< tm << endl;
    tm.reset();
    tm.start();
 
for (int i = 0; i < 1000; i++
{
        extractChannel(hsv1, hsvChannels2, 2);
        clahe->apply(hsvChannels2, hsvChannels2);
        insertChannel(hsvChannels2, hsv1, 2);
}
    tm.stop();
    cout<< tm;
    absdiff(hsv1, hsv2, diff);
    imshow("diff", diff*255);
    waitKey();
}

我运行这段代码的结果为:
4.63716sec
3.80283sec
应该说其中关键的一句就是使用:
extractChannel(hsv1hsvChannels2, 2);
代替
split(hsv2hsvChannels);
能够单句提高1MS左右时间,而这种费时的方法是我目前经常采用的,应该说这题很有较益。

三、基本算法

Compare two images and highlight the difference

Hi - First I'm a total n00b so please be kind. I'd like to create a target shooting app that allows me to us the camera on my android device to see where I hit the target from shot to shot. The device will be stationary with very little to no movement. My thinking is that I'd access the camera and zoom as needed on the target. Once ready I'd hit a button that would start taking pictures every x seconds. Each picture would be compared to the previous one to see if there was a change - the change being I hit the target. If a change was detected the two imaged would be saved, the device would stop taking picture, the image with the change would be displayed on the device and the spot of change would be highlighted. When I was ready for the next shot, I would hit a button on the device and the process would start over. If I was done shooting, there would be a button to stop.

Any help in getting this project off the ground would be greatly appreciated.

retag flag offensive
add a comment

This will be a very basic algorithm just to evaluate your use case. It can be improved a lot.

(i) In your case, the first step is to identify whether there is a change or not between 2 frames. It can be identified by using a simple StandardDeviation measurement. Set a threshold for acceptable difference in deviation.

Mat prevFrame, currentFrame;

for(;;)
{
    //Getting a frame from the video capture device.
    cap >> currentFrame;

    if( prevFrame.data )
    {
         //Finding the standard deviations of current and previous frame.
         Scalar prevStdDev, currentStdDev;
         meanStdDev(prevFrame, Scalar(), prevStdDev);
         meanStdDev(currentFrame, Scalar(), currentStdDev);

          //Decision Making.
          if(abs(currentStdDev - prevStdDev) < ACCEPTED_DEVIATION)
          {
               Save the images and break out of the loop.
          }     
    }

    //To exit from the loop, if there is a keypress event.
    if(waitKey(30)>=0)
        break;

    //For swapping the previous and current frame.
    swap(prevFrame, currentFrame);
}

(ii) The first step will only identify the change in frames. In order to locate the position where the change occured, find the difference between the two saved frames using AbsDiff. Using this difference image mask, find the contours and finally mark the region with a bounding rectangle.

Hope this answers your question.

flag offensive link

这道题难道不是对absdiff的应用吗?直接absdiff,然后阈值,数数就可以了。

四、系统配置

opencv OCRTesseract::create v3.05

I have the version of tesseract 3.05 and opencv3.2 installed and tested. But when I tried the end-to-end-recognition demo code, I discovered that tesseract was not found using OCRTesseract::create and checked the documentation to find that the interface is for v3.02. Is it possible to use it with Tesseract v3.05 ? How?

retag flag offensive

How to create OpenCV binary files from source with tesseract ( Windows )

image description

i tried to explain the steps

Step 1.download https://github.com/DanBloomberg/lepto...

extract it in a dir like "E:/leptonica-1.74.4"

run cmake

where is the source code : E:/leptonica-1.74.4

where to build binaries : E:/leptonica-1.74.4/build

click Configure buttonselect compiler

see "Configuring done"click Generate button and see "Generating done"

image description

Open Visual Studio 2015 >> file >> open "E:\leptonica-1.74.4\build\ALL_BUILD.vcxproj"select release, build ALL BUILD

see "Build: 3 succeeded" and be sure E:\leptonica-master\build\src\Release\leptonica-1.74.4.lib and E:\leptonica-1.74.4\build\bin\Release\leptonica-1.74.4.dll have been createdimage description


Step 2.download https://github.com/tesseract-ocr/tess...

extract it in a dir like "E:/tesseract-3.05.01"

create a directory E:\tesseract-3.05.01\Files\leptonica\include

copy *.h from E:\leptonica-master\src into E:\tesseract-3.05.01\Files\leptonica\includecopy *.h from E:\leptonica-master\build\src into E:\tesseract-3.05.01\Files\leptonica\include

run cmake

where is the source code : E:/tesseract-3.05.01

where to build binaries : E:/tesseract-3.05.01/build

click Configure buttonselect compiler

set Leptonica_DIR to E:/leptonica-1.74.4\buildclick Configure button againsee "Configuring done"click Generate button and see "Generating done"

Open Visual Studio 2015 >> file >> open "E:/tesseract-3.05.01\build\ALL_BUILD.vcxproj"build ALL_BUILD

be sure E:\tesseract-3.05.01\build\Release\tesseract305.lib and E:\tesseract-3.05.01\build\bin\Release\tesseract305.dll generated


Step 3.create directory E:\tesseract-3.05.01\include\tesseract

copy all *.h files from

E:\tesseract-3.05.01\api

E:\tesseract-3.05.01\ccmain

E:\tesseract-3.05.01\ccutil

E:\tesseract-3.05.01\ccstruct

to E:/tesseract-3.05.01/include\tesseract

in OpenCV cmake set Tesseract_INCLUDE_DIR : E:/tesseract-3.05.01/include

set tesseract_LIBRARY E:/tesseract-3.05.01/build/Release/tesseract305.lib

set Lept_LIBRARY E:/leptonica-master/build/src/Release/leptonica-1.74.4.lib

when you click Configure button you will see "Tesseract: YES" it means everything is OK

make other settings and generate. Compile ....

flag offensive link
禾路按语:OCR问题,一直都是图像处理的经典问题。那么tesseract是这个方向的非常经典的项目,包括east一起进行结合研究。

五、算法问题

Pyramid Blending with Single input and Non-Vertical Boundar

Hi All,

Here is the input image.image description

Say you do not have the other half of the images. Is it still possible to do with Laplacian pyramid blending?

I tried stuffing the image directly into the algorithm. I put weights as opposite triangles. The result comes out the same as the input.My another guess is splitting the triangles. Do gaussian and Laplacian pyramid on each separately, and then merge them.

But the challenge is how do we apply Laplacian matrix on triangular data. What do we fill on the missing half? I tried 0. It made the boundary very bright.

If pyramid blending is not the best approach for this. What other methods do you recommend me to look into for blending?

Any help is much appreciated!

retag flag offensive

Comments

the answer is YES.what you need is pyrdown the images and lineblend them at each pyramid

jsxyhelu gravatar imagejsxyhelu (26 hours ago)edit

Thank you for your comment. I tried doing that (explained by my 2nd paragraph). The output is the same as the original image. Please note where I want to merge is NOT vertical. So I do not get what you meant by "line blend".

这个问题需要实现的是mulitband blend,而且实现的是倾斜过来的融合,应该说很奇怪,不知道在什么环境下会有这样的需求,但是如果作为算法问题来说的话,还是很有价值的。首先需要解决的是倾斜的line bend,值得思考。

六、新玩意

DroidCam with OpenCV

With my previous laptop (Windows7) I was connecting to my phone camera via DroidCam and using videoCapture in OpenCV with Visual Studio, and there was no problem. But now I have a laptop with Windows 10, and when I connect the same way it shows orange screen all the time. Actually DroidCam app in my laptop works fine, it shows the video. However while using OpenCV videoCapture from Visual Studio it shows orange screen.

Thanks in advance

retag flag offensive
add a comment
Disable laptop webcam from device manager and then restart. Then it works

七、算法研究

OpenCV / C++ - Filling holes

Hello there,

For a personnel projet, I'm trying to detect object and there shadow. These are the result I have for now:Original: 

15384708243910086.png508489-20181008093950520-957877272.jpg

Object: 

Shadow: 

The external contours of the object are quite good, but as you can see, my object is not full.Same for the shadow.I would like to get full contours, filled, for the object and its shadow, and I don't know how to get better than this (I juste use "dilate" for the moment).Does someone knows a way to obtain a better result please?Regards.

有趣的问题,研究看看。



 


  



来自为知笔记(Wiz)


转载于:https://www.cnblogs.com/jsxyhelu/p/9752650.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/249341.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

云开发创建云函数

安装wx-server-sdk时候&#xff0c;终端报错如下&#xff1a; 解决方法&#xff1a; 运行&#xff1a;npm cache clean --force即可 转载于:https://www.cnblogs.com/moguzi12345/p/9758842.html

CSS3笔记之基础篇(一)边框

效果一、圆角效果 border-radius 实心上半圆&#xff1a; 方法&#xff1a;把高度(height)设为宽度&#xff08;width&#xff09;的一半&#xff0c;并且只设置左上角和右上角的半径与元素的高度一致&#xff08;大于也是可以的&#xff09;。 div {height:50px;/*是width…

CSS3笔记之基础篇(二)颜色和渐变色彩

效果一、颜色之RGBA RGB是一种色彩标准&#xff0c;是由红(R)、绿(G)、蓝(B)的变化以及相互叠加来得到各式各样的颜色。RGBA是在RGB的基础上增加了控制alpha透明度的参数。 语法&#xff1a; color&#xff1a;rgba(R,G,B,A) 以上R、G、B三个参数&#xff0c;正整数值的取值…

19_03_26校内训练[魔法卡片]

题意 有n张有序的卡片&#xff0c;每张卡片上恰有[1,m]中的每一个数&#xff0c;数字写在正面或反面。每次询问区间[l,r]&#xff0c;你可以将卡片上下颠倒&#xff0c;问区间中数字在卡片上方的并的平方和最大是多少。q,n*m≤1,000,000。 思考 一个很重要的性质&#xff0c;若…

CSS3笔记之基础篇(三)文字与字体

要点一、text-overflow与word-wrap text-overflow&#xff1a;设置是否使用一个省略标记&#xff08;...&#xff09;标示对象内文本的溢出。 word-wrap&#xff1a;设置文本行为&#xff0c;当前行超过指定容器的边界时是否断开转行。 语法如下&#xff1a; 注意&#xff1…

XV6操作系统代码阅读心得(二):进程

1. 进程的基本概念 从抽象的意义来说&#xff0c;进程是指一个正在运行的程序的实例&#xff0c;而线程是一个CPU指令执行流的最小单位。进程是操作系统资源分配的最小单位&#xff0c;线程是操作系统中调度的最小单位。从实现的角度上讲&#xff0c;XV6系统中只实现了进程&…

.Net Core 商城微服务项目系列(十二):使用k8s部署商城服务

一、简介 本篇我们将会把商城的服务部署到k8s中&#xff0c;同时变化的还有以下两个地方&#xff1a; 1.不再使用Consul做服务的注册和发现&#xff0c;转而使用k8s-dns来实现。 2.不再使用Ocelot作为业务网关&#xff0c;使用Traefik来实现。 正如上面所讲&#xff0c;服务发现…

CSS知识体系图谱

转自&#xff1a;https://blog.csdn.net/A13330069275/article/details/78448415

python2 pip安装包等出现各种编码错误UnicodeDecodeError: 'ascii'(/或者utf-8) codec can't decode byte 0xd2......

1.问题描述&#xff1a; python2环境&#xff0c;pip安装包时报错UnicodeDecodeError: ascii(/或者utf-8) codec cant decode byte 0xd2... 类似如下情况 2.原因分析 一开始依据网上给出的教程修改python安装路径下的各种文件&#xff0c;添加各种编码&#xff0c;始终无法解决…

leetcood学习笔记-111-二叉树的最小深度

题目描述&#xff1a; 第一次提交&#xff1a; class Solution(object):def minDepth(self, root):""":type root: TreeNode:rtype: int"""if not root:return 0if root.left and root.right:return min(self.minDepth(root.left)1,self.minDept…

IPV6 简单总结

1. 转帖别人的内容 来源&#xff1a;https://www.2cto.com/net/201112/114937.html 2. 本地用IPV6单播地址 (包括链路本地单播地址 和 站点本地单播地址) 2.1 链路本地单播地址 规定了链路本地和站点本地两种类型的本地使用单播地址。链路本地地址用在单链路上&#xff0c; 而…

面向对象第一单元总结

一、对面向对象的理解 有位同学给java的面向对象做了一个形象生动的类比&#xff0c;我觉得很有道理&#xff0c;大概按我的理解如下&#xff1a; 结构的形成看图之前&#xff0c;我们要先明白&#xff0c;世界上是先有了实体&#xff0c;才有了一步步抽象至以上的体系结构&…

理解HTML语义化

1、什么是HTML语义化&#xff1f; <基本上都是围绕着几个主要的标签&#xff0c;像标题&#xff08;H1~H6&#xff09;、列表&#xff08;li&#xff09;、强调&#xff08;strong em&#xff09;等等> 根据内容的结构化&#xff08;内容语义化&#xff09;&#xff0c;…

基本动态规划题集

观察下面的数字金字塔。写一个程序查找从最高点到底部任意处结束的路径&#xff0c;使路径经过数字的和最大。每一步可以从当前点走到左下方的点也可以到达右下方的点。 在上面的样例中,从13到8到26到15到24的路径产生了最大的和86。 【输入】 第一个行包含R(1≤ R≤1000)&…

python入门学习的第三天

step 1 时间 Python有两个模块&#xff0c;time和calendar&#xff0c;它们可以用于处理时间和日期 首先 import time 导入时间模块 然后 print time.time() 这个叫时间戳&#xff0c;它是从1970年1月1日午夜到现在时刻的秒数 print time.localtime(time.time()) print time.st…

.Net Core应用框架Util介绍(五)

上篇简要介绍了Util在Angular Ts方面的封装情况&#xff0c;本文介绍Angular封装的另一个部分&#xff0c;即Html的封装。 标准组件与业务组件 对于管理后台这样的表单系统&#xff0c;你通常会使用Angular Material或Ng-Zorro这样的UI组件库&#xff0c;它们提供了标准化的U…

Thunar 右键菜单等自定义

Thunar 右键菜单等自定义 可以使用图形界面或者直接编辑配置文件&#xff0c;二者是等价的。 图形界面&#xff1a; 以给“zip&#xff0c;rar&#xff0c;7z”等文件添加“在此位置使用unar解压缩”的右键菜单为例&#xff1a;&#xff08;unar可以很好地处理编码问题&#xf…

学习网站大汇集

一.综合类学习网站&#xff08;中文&#xff09; 1.网易公开课&#xff1a;https://open.163.com/。上面有TED、可汗学院、国内外高校公开课的免费资源。站内内容完全免费&#xff0c;良心推荐。 2.网易云课堂&#xff1a;http://study.163.com/。网易旗下付费学习平台&#…

@Scheduled

Scheduled注解的使用这里不详细说明&#xff0c;直接对8个参数进行讲解。 参数详解 cron 该参数接收一个cron表达式&#xff0c;cron表达式是一个字符串&#xff0c;字符串以5或6个空格隔开&#xff0c;分开共6或7个域&#xff0c;每一个域代表一个含义。 cron表达式语法 […

eclipse2019-03设置代码编辑区背景为图片

一、我的主题设置如下所示 二、找到如下所示或类似的文件夹 三、在该文件夹里的images文件夹里添加图片 四、在CSS目录下的e4-dark_win.css文件中添加如下代码   .MPart StyledText {     background-image: url(./bg.jpg);     background-repeat: no-repeat;  …