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(hsv1,?hsvChannels2,?2);
代替
split(hsv2,?hsvChannels);
能夠單句提高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.pswp.cn/news/249341.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/249341.shtml
英文地址,請注明出處:http://en.pswp.cn/news/249341.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Mysql 開啟遠程連接

在日常的數據庫的使用過程&#xff0c;往往會因為連接權限的問題搞得我們焦頭爛額&#xff0c;今天我把我們在數據庫連接上的幾個誤區簡單做個記錄。內容如下&#xff1a; 誤區一&#xff1a;MYSQL密碼和數據庫密碼的區別 mysql密碼是我們在安裝mysql服務是設置的密碼&#xf…

基于jsp+servlet完成的用戶注冊

思考 &#xff1a; 需要創建實體類嗎? 需要創建表嗎 |----User 存在、不需要創建了&#xff01;表同理、也不需要了 1.設計dao接口 package cn.javabs.usermanager.dao;import cn.javabs.usermanager.entity.User;/*** 用戶的dao接口的設計* author Mryang**/ public interfa…

vue resource then

https://www.cnblogs.com/chenhuichao/p/8308993.html

云開發創建云函數

安裝wx-server-sdk時候&#xff0c;終端報錯如下&#xff1a; 解決方法&#xff1a; 運行&#xff1a;npm cache clean --force即可 轉載于:https://www.cnblogs.com/moguzi12345/p/9758842.html

Java8新特性——函數式接口

目錄 一、介紹 二、示例 &#xff08;一&#xff09;Consumer 源碼解析 測試示例 &#xff08;二&#xff09;Comparator &#xff08;三&#xff09;Predicate 三、應用 四、總結 一、介紹 FunctionalInterface是一種信息注解類型&#xff0c;用于指明接口類型聲明…

CSS3筆記之基礎篇(一)邊框

效果一、圓角效果 border-radius 實心上半圓&#xff1a; 方法&#xff1a;把高度(height)設為寬度&#xff08;width&#xff09;的一半&#xff0c;并且只設置左上角和右上角的半徑與元素的高度一致&#xff08;大于也是可以的&#xff09;。 div {height:50px;/*是width…

JavaSE之Java基礎(1)

1、為什么重寫equals還要重寫hashcode 首先equals與hashcode間的關系是這樣的&#xff1a; 1、如果兩個對象相同&#xff08;即用equals比較返回true&#xff09;&#xff0c;那么它們的hashCode值一定要相同&#xff1b; 2、如果兩個對象的hashCode相同&#xff0c;它們并不一…

bootstarp table

https://www.cnblogs.com/laowangc/p/8875526.html

高級組件——彈出式菜單JPopupMenu

彈出式菜單JPopupMenu&#xff0c;需要用到鼠標事件。MouseListener必須要實現所有接口&#xff0c;MouseAdapter是類&#xff0c;只寫你關心的方法&#xff0c;即MouseAdapter實現了MouseListener中的方法 import javax.swing.*; import java.awt.*; import java.awt.event.Mo…

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;若…

vue 靜態圖片引入

https://blog.csdn.net/weixin_33862188/article/details/93325502

c:if test=/c:if 使用

1、頁面引用<%taglib uri"http://java.sun.com/jsp/jstl/core" prefix"c"%> 2、整形判斷&#xff1a; <c:if test"${TEST 1}"> </c:if> 3、判斷非空&#xff1a; <c:if test"${empty TEST}"> TEST為空 <…

CSS3筆記之基礎篇(三)文字與字體

要點一、text-overflow與word-wrap text-overflow&#xff1a;設置是否使用一個省略標記&#xff08;...&#xff09;標示對象內文本的溢出。 word-wrap&#xff1a;設置文本行為&#xff0c;當前行超過指定容器的邊界時是否斷開轉行。 語法如下&#xff1a; 注意&#xff1…

XV6操作系統代碼閱讀心得(二):進程

1. 進程的基本概念 從抽象的意義來說&#xff0c;進程是指一個正在運行的程序的實例&#xff0c;而線程是一個CPU指令執行流的最小單位。進程是操作系統資源分配的最小單位&#xff0c;線程是操作系統中調度的最小單位。從實現的角度上講&#xff0c;XV6系統中只實現了進程&…

webservices

https://blog.csdn.net/VitaminZH/article/details/81123571

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

一、簡介 本篇我們將會把商城的服務部署到k8s中&#xff0c;同時變化的還有以下兩個地方&#xff1a; 1.不再使用Consul做服務的注冊和發現&#xff0c;轉而使用k8s-dns來實現。 2.不再使用Ocelot作為業務網關&#xff0c;使用Traefik來實現。 正如上面所講&#xff0c;服務發現…

HTML、CSS知識點總結,淺顯易懂。

一&#xff0c;htmlcss基礎 1-1 Html和CSS的關系 學習web前端開發基礎技術需要掌握&#xff1a;HTML、CSS、JavaScript語言。下面我們就來了解下這三門技術都是用來實現什么的&#xff1a; 1. HTML是網頁內容的載體。內容就是網頁制作者放在頁面上想要讓用戶瀏覽的信息&#xf…

Thinking in Java 源代碼 source code 在IDEA上運行

參考我52的文章&#xff1a;https://www.52pojie.cn/thread-912471-1-1.html 轉載于:https://www.cnblogs.com/AI-Cobe/p/10605434.html

CSS知識體系圖譜

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