i started with OPENCV js tutorials 2 days ago.Now i can do my basic editing and image-processing operations on 2D videos but How can i do that this editing and image -processing operations in VR videos?I am looking for javascript library that can do editing and image-processing operations on my VR videos.How can i get started?
↧
How to implement image processing on virtual reality videos with javascript?
↧
GrabCut usage
Hey everyone,
I haven't found a definitive answer to this question hence I'm reaching out to the community.
**Can GrabCut code from the core OpenCV repository be used in commercial projects?**
The underlying method is patented by Microsoft, so the question is how much implementation of the OpenCV GrabCut differs from the one listed in a patent document.
**Did anyone use GrabCut in a commercial project here?**
↧
↧
Movidius or a GPU would be better
please dont dislike,This is only meant for an advice
I am in need of some deep learning acclerators.Recentely i heard about intel's neural compute stick(movidius) and also heard that it supports opencv.Of the same price i found many nvidea gpu. My head is conflicting among these product. Shall i buy a GPU rather movidus or shall i buy movidus instead.I think gpu in a pc can do more than just deep learning,like games..:)
From inside i feel to buy a gpu instead .but before any step i would like to take advice from expert or those who have experience about it.I want to judge on the basis of performance and experience
↧
Movidius or a GPU would be better
please don't dislike,This is only meant for an advice
I am in need of some deep learning acclerators.Recentely i heard about intel's neural compute stick(movidius) and also heard that it supports opencv.Of the same price i found many nvidea gpu. My head is conflicting among these product. Shall i buy a GPU rather movidus or shall i buy movidus instead.I think gpu in a pc can do more than just deep learning,like games..:)
From inside i feel to buy a gpu instead .but before any step i would like to take advice from expert or those who have experience about it.I want to judge on the basis of performance and experience
↧
Trying to implement Lego Java core code in C++
I am in the process of implementing the Lego LeJos core in C++. I have the OpenCV samples "Contours" and "drawContours" running. I am using them to convert the Lego software from Java to C++. I get all the way to "drawContours". At that point I am stuck. "imshow" hits an error. The program stops at ...
int idx = 0; // From "drawContours.cpp"
for (; idx >= 0; idx = hierarchy[idx][0]) { // From "drawContours.cpp"
Countt += 1;
cout << Countt;
printf("\n");
//idx = hierarchy[idx][0];
drawContours(
dst, // Image
contours, // Contours
idx, // Contouridx
color, // Color
1, // Thickness, Defalt = 1
LINE_8, // LineType, Defalt = LINE_8,
hierarchy); // Hierarchy =
}
imshow("After drawContours", dst);
The entire program is ...
#include "stdafx.h"
#include
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
using namespace std;
using namespace cv;
/// Global Variables
int DELAY_CAPTION = 1500;
int DELAY_BLUR = 100;
int MAX_KERNEL_LENGTH = 31;
Mat src; Mat dst;
Mat frame;
char window_name[] = "Smoothing Demo";
int bias = 0;
int Countt = 0;
/// Function headers
int display_caption(const char* caption);
int display_dst(int delay);
vector> contours;
vector hierarchy;
/**
* function main
*/
int main(int argc, char ** argv)
{
Mat frame;
frame = imread("lena.jpg");
printf("lena.jpg\n");
imshow("Lena.jpg", frame);
waitKey();
//Mat roi = new Mat(frame, new Rect(10, 2 * frame.rows() / 3, frame.cols() - 20, camImage.rows() / 12));
//Mat roi = Mat (frame, new Rect(10, 10, 10, 10));
Mat mono;
printf("cvtColor\n");
cvtColor(frame, mono, COLOR_BGR2GRAY);
imshow("cvtColor", mono);
waitKey();
Mat Iblur;
printf("GaussianBlur\n");
GaussianBlur(mono, Iblur, Size(9, 9), 2, 2);
imshow("GaussionBlur", Iblur);
waitKey();
Mat thresh;
printf("threshold\n");
threshold(Iblur, thresh, 0, 255, THRESH_BINARY_INV | THRESH_OTSU);
imshow("threshold", thresh);
waitKey();
Mat erodeImg;
printf("Before erode\n");
erode(thresh, erodeImg, 1);
imshow("After erode", erodeImg);
waitKey();
Mat dilateImg;
printf("Before dilate\n");
dilate(erodeImg, dilateImg, 1);
imshow("After dilate", dilateImg);
waitKey();
//List contours = new ArrayList();
printf("Before findcontours\n");
findContours(dilateImg, contours, hierarchy, RETR_LIST, CHAIN_APPROX_SIMPLE);
imshow("After findContours", dilateImg);
waitKey();
vector> contours;
vector cont;
cout << Countt;
printf("\n");
Scalar color(rand() & 255, rand() & 255, rand() & 255);
int idx = 0; // From "drawContours.cpp"
for (; idx >= 0; idx = hierarchy[idx][0]) { // From "drawContours.cpp"
Countt += 1;
cout << Countt;
printf("\n");
drawContours(
dst, // Image
contours, // Contours
idx, // Contouridx
color, // Color
1, // Thickness, Defalt = 1
LINE_8, // LineType, Defalt = LINE_8,
hierarchy); // Hierarchy =
}
imshow("After drawContours", dst);
waitKey();
↧
↧
Compiling opencv with qt support (linux)
I followed the instructions page to download opencv3 source and installed with default settings. I assumed this would by default compile with qt support. But this doesn't seem to be the case as seen by the following error: `OpenCV Error: The function/feature is not implemented (The library is compiled without QT support) in createButton`
[This question](http://answers.opencv.org/question/60249/the-library-is-compiled-without-qt-support-in-function-displayoverlay/) suggests the WITH_QT flag but I'm not sure where to set that. Moreover, when I run `cv::getBuildInformation()` as suggested in that question, this is some of the output I get. A couple of things I have noticed is:
> QT 5.x: YES (ver 5.5.1)
QT OpenGL support: NO
OpenGL support: NO
VTK support: YES (ver 6.2.0)> Install path: /opt/ros/kinetic
but this is not the install path that I provided when I installed it. I can see it being installed in /usr/local, yet this is the output I get. I did have ROS installed separately, that also does come with opencv libraries so I'm not sure where the conflict is
↧
Static linking help needed when including the viz module (VTK)
Hey all!
I'm having an issue I've been fighting with all weekend. I'm trying to build a fairly simple example which uses the viz module in C++. I've built OpenCV 3.4 and OpenCV-contrib along with VTK 8.1.0 as static libs and all seems to be well there. But after adding all the libs and appropriate includes I get 19 build errors I can't seem to resolve and they all seem to be related to the opengl libraries within vtk.
opencv_viz340d.lib(opencv_viz_pch.obj) : error LNK2019: unresolved external symbol "void __cdecl vtkRenderingOpenGL2_AutoInit_Construct(void)" (?vtkRenderingOpenGL2_AutoInit_Construct@@YAXXZ) referenced in function "public: __thiscall vtkRenderingCore_AutoInit::vtkRenderingCore_AutoInit(void)" (??0vtkRenderingCore_AutoInit@@QAE@XZ)
opencv_viz340d.lib(opencv_viz_pch.obj) : error LNK2019: unresolved external symbol "void __cdecl vtkRenderingOpenGL2_AutoInit_Destruct(void)" (?vtkRenderingOpenGL2_AutoInit_Destruct@@YAXXZ) referenced in function "public: __thiscall vtkRenderingCore_AutoInit::~vtkRenderingCore_AutoInit(void)" (??1vtkRenderingCore_AutoInit@@QAE@XZ)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "public: virtual void __thiscall vtkOpenGLGL2PSHelper::PrintSelf(class std::basic_ostream>&,class vtkIndent)" (?PrintSelf@vtkOpenGLGL2PSHelper@@UAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@VvtkIndent@@@Z) referenced in function "public: virtual void __thiscall vtkOpenGLGL2PSHelperImpl::PrintSelf(class std::basic_ostream>&,class vtkIndent)" (?PrintSelf@vtkOpenGLGL2PSHelperImpl@@UAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@VvtkIndent@@@Z)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "protected: __thiscall vtkOpenGLGL2PSHelper::vtkOpenGLGL2PSHelper(void)" (??0vtkOpenGLGL2PSHelper@@IAE@XZ) referenced in function "protected: __thiscall vtkOpenGLGL2PSHelperImpl::vtkOpenGLGL2PSHelperImpl(void)" (??0vtkOpenGLGL2PSHelperImpl@@IAE@XZ)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "protected: virtual __thiscall vtkOpenGLGL2PSHelper::~vtkOpenGLGL2PSHelper(void)" (??vtkOpenGLGL2PSHelper@@MAE@XZ) referenced in function "protected: virtual __thiscall vtkOpenGLGL2PSHelperImpl::~vtkOpenGLGL2PSHelperImpl(void)" (??1vtkOpenGLGL2PSHelperImpl@@MAE@XZ)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "public: unsigned int __thiscall vtkTransformFeedback::GetBytesPerVertex(void)const " (?GetBytesPerVertex@vtkTransformFeedback@@QBEIXZ) referenced in function "public: virtual void __thiscall vtkOpenGLGL2PSHelperImpl::ProcessTransformFeedback(class vtkTransformFeedback *,class vtkRenderer *,float * const)" (?ProcessTransformFeedback@vtkOpenGLGL2PSHelperImpl@@UAEXPAVvtkTransformFeedback@@PAVvtkRenderer@@QAM@Z)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "public: unsigned int __thiscall vtkTransformFeedback::GetBufferSize(void)const " (?GetBufferSize@vtkTransformFeedback@@QBEIXZ) referenced in function "public: virtual void __thiscall vtkOpenGLGL2PSHelperImpl::ProcessTransformFeedback(class vtkTransformFeedback *,class vtkRenderer *,float * const)" (?ProcessTransformFeedback@vtkOpenGLGL2PSHelperImpl@@UAEXPAVvtkTransformFeedback@@PAVvtkRenderer@@QAM@Z)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol __imp__glGetDoublev@8 referenced in function "protected: static void __cdecl vtkOpenGLGL2PSHelperImpl::GetTransformParameters(class vtkRenderer *,class vtkMatrix4x4 *,class vtkMatrix4x4 *,double * const,double * const,double * const)" (?GetTransformParameters@vtkOpenGLGL2PSHelperImpl@@KAXPAVvtkRenderer@@PAVvtkMatrix4x4@@1QAN22@Z)
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function _gl2psDrawImageMap
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function _gl2psDrawImageMap
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glFeedbackBuffer@12 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glGetBooleanv@8 referenced in function _gl2psDrawPixels
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glGetFloatv@8 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glGetIntegerv@8 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glIsEnabled@4 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glPassThrough@4 referenced in function _gl2psDrawPixels
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glRenderMode@4 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glVertex3f@12 referenced in function _gl2psDrawImageMap
I don't quite understand the error. I've looked at the VTK code and clearly there is a constructor defined as well as other methods mentioned, and the vtkRenderingOpenGL2-8.1.lib is referenced in the application (I referenced all libs). Any help would be appreciated!
↧
Shadow Removal in Traffic Lane Lines
I am working on lane lines detection. My current working strategy is:
1. defining a region of interest where lane lines could be
2. Warping the image to get a bird eye view
3. Converting the image to YUV color space
4. Normalizing the Y channel
5. Fitting the second order polynomial and sliding window approach
every thing works fine but where there are shadows the algorithm do not work.
I have tried adaptive thresholding, otssu thresholding but not succeeded.
[Source Image without Shadow][1]
[Processed Source Image without Shadow][2]
[Source Image with Shadow][3]
[Processed Source Image with Shadow][4]
In the second Image it can be seen that the shadowed area is not detected. Actually shadows drops the image values down so i tried to threshold the image with new values lower than the previous one new image can be found [here][5]
This technique does not work as it comes with a lot of noise
Currently I am trying background subtraction and shadow removal techniques but its not working. I am struck in this problem from last 2 3 weeks.
Any help will really be appreciated...
import cv2
import matplotlib.pyplot as plt
import numpy as np
from helper_functions import undistort, threshholding, unwarp,sliding_window_polyfit
from helper_functions import polyfit_using_prev_fit,calc_curv_rad_and_center_dist
from Lane_Lines_Finding import RoI
img = cv2.imread('./test_images/new_test.jpg')
new =undistort(img)
new = cv2.cvtColor(new, cv2.COLOR_RGB2BGR)
#new = threshholding(new)
h,w = new.shape[:2]
# define source and destination points for transform
imshape = img.shape
vertices = np.array([[
(257,670),
(590, 446),
(722, 440),
(1150,650)
]],
dtype=np.int32)
p1 = (170,670)
p2 = (472, 475)
p3 = (745, 466)
p4 = (1050,650)
vertices = np.array([[p1,
p2,
p3,
p4
]],
dtype=np.int32)
masked_edges = RoI(new, vertices)
#masked_edges = cv2.cvtColor(masked_edges, cv2.COLOR_RGB2BGR)
src = np.float32([(575,464),
(707,464),
(258,682),
(1049,682)])
dst = np.float32([(450,0),
(w-450,0),
(450,h),
(w-450,h)])
warp_img, M, Minv = unwarp(masked_edges, src, dst)
warp_img = increase_brightness_img(warp_img)
warp_img = contrast_img(warp_img)
YUV = cv2.cvtColor(warp_img, cv2.COLOR_RGB2YUV)
Y,U,V = cv2.split(YUV)
Y_equalized= cv2.equalizeHist(Y)
YUV = cv2.merge((Y,U,V))
thresh_min = 253
thresh_max = 255
binary = np.zeros_like(Y)
binary[(Y_equalized>= thresh_min) & (Y_equalized <= thresh_max)] = 1
kernel_opening= np.ones((3,3),np.uint8)
opening = cv2.morphologyEx(binary, cv2.MORPH_OPEN, kernel_opening)
kernel= np.ones((7,7),np.uint8)
dilation = cv2.dilate(opening,kernel,iterations = 3)
[1]: http://tinyimg.io/i/JpUTFtV.png
[2]: http://tinyimg.io/i/8eVX5uC.png
[3]: http://tinyimg.io/i/t7ezuAp.png
[4]: http://tinyimg.io/i/ZbRO53w.png
[5]: http://tinyimg.io/i/kDPQQnR.png
↧
Static linking help needed when including the viz module (VTK)
Hey all!
I'm having an issue I've been fighting with all weekend. I'm trying to build a fairly simple example which uses the viz module in C++. I've built OpenCV 3.4 and OpenCV-contrib along with VTK 8.1.0 as static libs and all seems to be well there. But after adding all the libs and appropriate includes I get 19 build errors I can't seem to resolve and they all seem to be related to the opengl libraries within vtk.
opencv_viz340d.lib(opencv_viz_pch.obj) : error LNK2019: unresolved external symbol "void __cdecl vtkRenderingOpenGL2_AutoInit_Construct(void)" (?vtkRenderingOpenGL2_AutoInit_Construct@@YAXXZ) referenced in function "public: __thiscall vtkRenderingCore_AutoInit::vtkRenderingCore_AutoInit(void)" (??0vtkRenderingCore_AutoInit@@QAE@XZ)
opencv_viz340d.lib(opencv_viz_pch.obj) : error LNK2019: unresolved external symbol "void __cdecl vtkRenderingOpenGL2_AutoInit_Destruct(void)" (?vtkRenderingOpenGL2_AutoInit_Destruct@@YAXXZ) referenced in function "public: __thiscall vtkRenderingCore_AutoInit::~vtkRenderingCore_AutoInit(void)" (??1vtkRenderingCore_AutoInit@@QAE@XZ)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "public: virtual void __thiscall vtkOpenGLGL2PSHelper::PrintSelf(class std::basic_ostream>&,class vtkIndent)" (?PrintSelf@vtkOpenGLGL2PSHelper@@UAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@VvtkIndent@@@Z) referenced in function "public: virtual void __thiscall vtkOpenGLGL2PSHelperImpl::PrintSelf(class std::basic_ostream>&,class vtkIndent)" (?PrintSelf@vtkOpenGLGL2PSHelperImpl@@UAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@VvtkIndent@@@Z)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "protected: __thiscall vtkOpenGLGL2PSHelper::vtkOpenGLGL2PSHelper(void)" (??0vtkOpenGLGL2PSHelper@@IAE@XZ) referenced in function "protected: __thiscall vtkOpenGLGL2PSHelperImpl::vtkOpenGLGL2PSHelperImpl(void)" (??0vtkOpenGLGL2PSHelperImpl@@IAE@XZ)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "protected: virtual __thiscall vtkOpenGLGL2PSHelper::~vtkOpenGLGL2PSHelper(void)" (??vtkOpenGLGL2PSHelper@@MAE@XZ) referenced in function "protected: virtual __thiscall vtkOpenGLGL2PSHelperImpl::~vtkOpenGLGL2PSHelperImpl(void)" (??1vtkOpenGLGL2PSHelperImpl@@MAE@XZ)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "public: unsigned int __thiscall vtkTransformFeedback::GetBytesPerVertex(void)const " (?GetBytesPerVertex@vtkTransformFeedback@@QBEIXZ) referenced in function "public: virtual void __thiscall vtkOpenGLGL2PSHelperImpl::ProcessTransformFeedback(class vtkTransformFeedback *,class vtkRenderer *,float * const)" (?ProcessTransformFeedback@vtkOpenGLGL2PSHelperImpl@@UAEXPAVvtkTransformFeedback@@PAVvtkRenderer@@QAM@Z)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "public: unsigned int __thiscall vtkTransformFeedback::GetBufferSize(void)const " (?GetBufferSize@vtkTransformFeedback@@QBEIXZ) referenced in function "public: virtual void __thiscall vtkOpenGLGL2PSHelperImpl::ProcessTransformFeedback(class vtkTransformFeedback *,class vtkRenderer *,float * const)" (?ProcessTransformFeedback@vtkOpenGLGL2PSHelperImpl@@UAEXPAVvtkTransformFeedback@@PAVvtkRenderer@@QAM@Z)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol __imp__glGetDoublev@8 referenced in function "protected: static void __cdecl vtkOpenGLGL2PSHelperImpl::GetTransformParameters(class vtkRenderer *,class vtkMatrix4x4 *,class vtkMatrix4x4 *,double * const,double * const,double * const)" (?GetTransformParameters@vtkOpenGLGL2PSHelperImpl@@KAXPAVvtkRenderer@@PAVvtkMatrix4x4@@1QAN22@Z)
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function _gl2psDrawImageMap
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function _gl2psDrawImageMap
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glFeedbackBuffer@12 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glGetBooleanv@8 referenced in function _gl2psDrawPixels
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glGetFloatv@8 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glGetIntegerv@8 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glIsEnabled@4 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glPassThrough@4 referenced in function _gl2psDrawPixels
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glRenderMode@4 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glVertex3f@12 referenced in function _gl2psDrawImageMap
I don't quite understand the error. I've looked at the VTK code and clearly there is a constructor defined as well as other methods mentioned, and the vtkRenderingOpenGL2-8.1.lib is referenced in the application (I referenced all libs). Any help would be appreciated!
↧
↧
How to use OpenCV in JAVA for minicomputers?
Is there anyway to use OpenCV in java for minicomputers (such as my Odroid XU4 that runs Ubuntu Mate, or RASPBERRY PI 3)?. Now here is my problem, where I got a single-board computer from HaredKernel.com, and it is the new Odroid XU4 with an ARM Cortex-A7 CPU, where i followed this tutorial "https://docs.opencv.org/2.4/doc/tutorials/introduction/crosscompilation/arm_crosscompile_with_cmake.html?" to compile OpenCV v 3.3.1 using CMake for ARM based CPU's but CMake never recognizes my ARM JDK, nor my Linux-based x64 JDK (Where Java is necessary to build OpenCV's .Jar and .so files).
Please note that i already succeeded with compiling OpenCV v 3.3.1 for Java on both Linux x64 and x86 based platforms by following this tutorial "https://advancedweb.hu/2016/03/01/opencv_ubuntu/".
So is it right to compile OpenCV for Java to work on my Odroid XU4 this way, or is there any precompiled versions of it for such platforms?
↧
How to remove those specified label component by fastest method
Cross post [here](https://stackoverflow.com/questions/48664698/how-to-remove-those-specified-label-component-by-fastest-method)
----------
Suppose I have an such binary image
Mat img(1000, 2000, CV_8UC1);
randu(img, Scalar(0), Scalar(255));
inRange(img, Scalar(160), Scalar(200), img);
I will use `connectedComponentsWithStats` to label the `img`
Mat labels, stats, centroids;
int counts_img = connectedComponentsWithStats(img, labels, stats, centroids);
And I will specify some labels to remove from `labels`.
vector drop_label(counts_img - 3);
iota(drop_label.begin(), drop_label.end(), 1);
Of course I can do it with following method:
Mat img(1000, 2000, CV_8UC1);
randu(img, Scalar(0), Scalar(255));
inRange(img, Scalar(160), Scalar(200), img);
Mat labels, stats, centroids;
int counts_img = connectedComponentsWithStats(img, labels, stats, centroids);
vector drop_label(counts_img - 3);
iota(drop_label.begin(), drop_label.end(), 1);
//start to count the time.
double start_time = (double)getTickCount();
Mat select = img.clone() = 0;
int img_height = img.rows, img_width = img.cols;
for (int i = 0; i < img_height; i++) {
int*plabels = labels.ptr(i);
uchar*pselect = select.ptr(i);
for (int j = 0; j < img_width; j++) {
if (find(drop_label.begin(), drop_label.end(), plabels[j]) != drop_label.end())
pselect[j] = 255;
}
}
Mat result = img - select;
//total time
double total_time = ((double)getTickCount() - start_time) / getTickFrequency();
cout << "total time: " << total_time << "s" << endl;
> `total time: 96.8676s`
As you see, I can do it indeed, and as I know, the `.ptr` is the fastest methd. but I have to say I cannot bear the function `find` cost my so many time. Any body can tell me a fastest method to do this?
↧
What does isContourConvex actually do?
Hi,
I am using `isContourConvex` to remove some contours in my image and it also works quite well. But now I want to know what the function actually does?
I found some threads where it says, that `isContourConvex` can distinguish between closed and open contours. In my example "boomerang-shaped" contours which **in fact are closed** get marked as false and I can remove them (exactly what I want).
I found this: https://docs.opencv.org/2.4/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html
and this: https://github.com/opencv/opencv/blob/master/modules/imgproc/src/convhull.cpp
but the explanation is really small and I don't understand the source code.
↧
how to extract text from very small image using python opencv
Hi All,
I'm new bee for python openCV, can you help me to extract text from small image.Can you check my uploaded image.
i have tried Below code, But i'm not getting expected result.
import sys
import cv2
import numpy as np
import pytesseract
img = Image.open("TestImge.PNG")
pytesseract.pytesseract.tesseract_cmd = 'F:\\Python27\\Tesseract-OCR\\tesseract'
print(pytesseract.image_to_string(img))
**my Expected output Is**
Show the following Claims
**But i'm getting**
Sltowvcololovangccrno
**my image**

Help me to done.
Thanks,
↧
↧
Does modifying ROI of an image will also impact the image itself?
Hello.
I have code which looks like this:
cv::Mat image = getImage(); // CV_32FC3
cv::Rect roi = getROI();
if (condition1) {
cv::Mat part;
if (condition2) {
part = image;
} else {
part = image(roi);
}
// This sometimes evaluates as 'false' and raises an exception
assert(part.data == image.data);
// This is expected to also impact the 'image' matrice
cv::addWeighted(part, 0.5, getMask(), 0.5, 0.0, part);
}
// [...] Continue modifying 'image'
Basically, I want to modify a "global" image based on a first `condition1`. Then, according to the `condition2`, I need to modify the image partially or entirely.
Can I expect this code to work in all cases (removing the `assert` statement)? That is, that the modification applied to `part` will also be visible on `image`.
I have doubts because of the `assert` that sometimes is `true` and sometimes is `false` (with the ROI). I imagine that under certain conditions, the pointer `part.data` can designate a address with some offset compared to `image.data`, that is why the assertion fails (but still, there is `image.data + offset == part.data`)?
↧
memory leak in Mat.put(int,int,byte[])? or wrong usage? (Java)
G'day!
My application is reading in a lot of `BufferedImage`, eventually transforming them into OpenCv-`Mat` objects for processing. Ho to do this is described - e.g. - here: https://stackoverflow.com/questions/14958643/converting-bufferedimage-to-mat-in-opencv . (The application is using the BI _and_ the Mat, so the BI are needed.)
There seems to be a problem, though: it seems the application is eating up memory during conversion - native memory, not Java heap. I narrowed down this (suspected) memory leak to setting the `Mat` contents from a `byte[]`. Could anyone confirm this is a memory leak, or (preferably) explain to me, that I'm using `Mat` in an incorrect way here (and hint me to the right path)? I searched the big, wide WWW for a while now and couldn't find anything that seems to match.
Below you'll find a code snippet that showcases my findings. The variant 1 emulates there being different images getting converted to `Mat`; variant 2 simplifies the example, but also drastically changes it's behaviour. I chose sizes to get my system into using swap, so be sure to adjust the numbers before running the example. The uses of `showMessageDialog` could also be substituted by e.g. `Thread.sleep(...)`.
Observation: the code, when run, allocates more memory than I'd expect. The first `gc()` will do nearly nothing. The calls to `Mat.release()` seem to free up quite a lot of memory (as expected), but a lot stays allocated. Letting go of the object reference to `mats` doesn't change anything.
Latest at this point I'd expect all memory (`byte[]` and `Mat`) to be freed, but it isn't - and the memory still allocated is not within the Java heap, so must be native memory. The memory not getting freed seems to be the memory allocated for the `byte[]`, which can be shown by trying variant 2 instead of variant 1.
I'm using OpenCV 3.2.0 here, more precise: the maven-distributed version of https://github.com/openpnp/opencv . 3.2.0 is not the latest version, but fairly recent. Anyhow: any hints that this problem was already addressed between 3.2.0 and the latest release would also be welcome.
Any ideas?
The code snippet [retyped here, so pls be merciful in case of typos]:
final int dim = 10000; // vvv
final int count = 100; // these should amount to ~ 10G mem usage, adjust as needed
// byte[] pixels = new byte[ dim * dim]; // Variant 2
Mat[] mats = new Mat[ count ];
for( int i=0; i m.release() );
System.gc();
System.out.println("released mats and gc'd");
JOptionPane.showMessageDialog( null, "click to continue", "Godot", JOptionPane.INFORMATON_MESSAGE );
mats = null;
System.gc();
System.out.println("let go of reference and gc'd");
JOptionPane.showMessageDialog( null, "click to stop", "Godot", JOptionPane.INFORMATON_MESSAGE );
(NB: Yes, `System.gc()` is just a hint to the JVM, but the JVM seems to gc every time.)
↧
Bottle Detection
Hello,
I have the following application:
Attached you can see some Images, it is a White Container with some different bottles in it (I made 4 Pictures to see the structure of this). There are 6 positions for the bottles, and 2 different bottle types in it. In different applications, all of the 6 positions can have a big bottle (called "tube"), a small bottle (called "Cup") or be empty. In the example Images you can see 2 Tubes, 2 Cups and 2 Empty positions.
A Camera is looking from the front to this Container, like in Image IMG_0001.JPG. The Task is to detect one of the 3 Options for each of the 6 positions (Is there a tube, a Cup or empty).
- Additional Infos: Please do not consider the data Matrix codes on the backside, just ignore them.
- The red lid of the large tubes is not present, please also ignore them (I forgot to unplug them before making Pictures)
How would you solve this Problem with OpenCV? Would you suggest a Special Illumination?
Thank you for helping


↧
Scale Factor for Undistortion Matrix
I ran the calibration successfully on my image, and the undistortion worked great. Now I want to do it my hand, and I seem to be off by a scaling factor.
On the first page of the Calibration tutorial:
https://docs.opencv.org/2.4/doc/tutorials/calib3d/camera_calibration/camera_calibration.html
the equation for removing radial distortion is
x' = x(1+k1 r^2 + k2 r^4 + k3 r^6)
My camera matrix says that the center of my image is at (x0,y0) = (630,470)
I want to undistort a point in the picture at pixel location (70,70). So I calculate my r as:
sqrt( (630-70)^2 + (470-70)^2 ) = 688.
With my k values, I get an x' in the zillions, so clearly I need to scale my numbers before using the equation. Can someone tell me how to do this?
↧
↧
network proxy
Is there a configuration option for a a network proxy so that a video stream such as MJPEG over http can be accessed from behind an enterprise firewall/proxy? Such a capability exists for VLC.
↧
SIFT match against database of images
I'm trying to build some application, that is trying to guess if some image was stored in database.
Generally speaking, I have vector of matched features for my image and vector of features, extracted for other images. And I'm stuck because I don't know how can I detect if some of these images are similar to my requested image or not.
[Here is sample code](https://docs.opencv.org/3.1.0/d5/d6f/tutorial_feature_flann_matcher.html) from documentation which is working as one-to-one comparision, but it doesn't work well with thousands of images. All descriptors that can be "trained" just expects that all these features are describing the same image from different angles, but in practice I have set of completely unrelated images.
What is the best approach? Does OpenCV shipps with required functionnality?
↧
make is failed: opencv_test_stab
I have ubuntu 16.04 with python 3.5
I am trying to install opencv without CUDA and the make is failed with the following error message:
[C:\fakepath\opencv.png](/upfiles/15178466361645434.png)
collect2: error: ld returned 1 exit status
modules/world/CMakeFiles/opencv_test_videostab.dir/build.make:127: recipe for target 'bin/opencv_test_videostab' failed
Is there any idea how to resolve the problem?
↧