w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Matlab gradient equivalent in opencv
You have to call Sobel 2 times, with arguments: xorder = 1, yorder = 0 and xorder = 0, yorder = 1 You have to select the appropriate kernel size. See documentation It might still be that the MatLab implementation was different, ideally you should retrieve which kernel was used there... Edit: If you need to specify your own kernel, you can use the more generic filter2D. Your destination depth will be CV_16S (16bit signed).

Categories : Matlab

rgb2lab discrepancy opencv and matlab
Please refer to function rgb2lab(int R, int G, int B, int []lab) in this page. The idea is first convert to XYZ and then to lab. It also contains conversions between other color spaces.

Categories : C++

Matlab imagesc clims to OpenCV
I found the solution. Before doing the normalization I just found all the matrix elements larger than m+s*3 and changed them to m+s*3, and all the elements smaller than m+s*-3 and changed them to m+s*-3. After doing this with the matrix elements I did the normalization to range from 0 to 1. Same result like in MATLAB's imagesc with clims.

Categories : Matlab

Different Pixel Values in MATLAB and C++ with OpenCV
You are converting the image if certain conditions are met, this can change some color values while MATLAB can choose to not convert the image but use the raw image colors are mostly represented in hex format with popular implementations in the format of 0xAARRGGBB or 0xRRGGBBAA, so 32 bit integers will do (unsigned/signed doesn't matter, the hex value is still the same), create a 64 bit variable, add all the 32 bit variables together and then divide by the amount of pixels, this will get you a quite accurate result (for images up to 16384 by 16384 pixels (where a 32 bit value is representing the color of one pixel), if larger, then a 64 bit integer will not be enough). long long total = 0; long long divisor = image.width * image.height; for(int x = 0; x < image.width; ++x) { for(

Categories : C++

Disk Structuring Element opencv vs Matlab
According to the docs, you could try: cv::Mat sel = cv::getStructuringElement(MORPH_ELLIPSE, cv::Size(9,9)); This gave me the following structuring element: 0 0 0 0 1 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0 0 While in MATLAB I got: >> getnhood(strel('disk',5)) ans = 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1

Categories : C++

Different SURF Features Extracted Between MATLAB and OpenCV?
Under the hood, MATLAB uses OpenCV for some of its computer vision functions, including detecting SURF features. If you look inside the $matlabroot/bin/$arch folder, you'll find OpenCV shared libraries in addition to a gateway library ocv.dll). In fact, the same reference paper is mentioned in the documentation of both, which suggests that the algorithm parameters have the same meaning in both frameworks. MATLAB Herbert Bay, Andreas Ess, Tinne Tuytelaars, Luc Van Gool "SURF: Speeded Up Robust Features", Computer Vision and Image Understanding (CVIU), Vol. 110, No. 3, pp. 346--359, 2008 OpenCV Bay, H. and Tuytelaars, T. and Van Gool, L. "SURF: Speeded Up Robust Features", 9th > European Conference on Computer Vision, 2006 First thing, make sure you are using the same pa

Categories : Matlab

matlab find function implementation in opencv?
Assuming Color is a properly initialized single-channel cv::Mat, you can use the combination of overloaded operator== and cv::countNonZero() to do what you wish. operator== returns a mask where each element is one if the value in Color matches j, or zero otherwise. if(cv::countNonZero(Color == j)) { // Do something... }

Categories : C++

Sobel filter output from opencv and Matlab different
This code gives me the same result as MATLAB code: int main(int argc, char* argv[]) { namedWindow("result"); Mat img=imread("D:\ImagesForTest\1.tiff",0); img.convertTo(img,CV_32FC1,1.0/255.0); Mat h,v,g; cv::Sobel(img,h,-1,1,0,3,1.0/8.0); cv::Sobel(img,v,-1,0,1,3,1.0/8.0); cv::magnitude(h,v,g); // Check extremums double m,M; cv::minMaxLoc(g,&m,&M); cout << m << ":" << M << endl; cv::minMaxLoc(h,&m,&M); cout << m << ":" << M << endl; cv::minMaxLoc(v,&m,&M); cout << m << ":" << M << endl; imshow("result",g); cv::waitKey(0); } OpenCV never scales convolution result, so, be careful.

Categories : C++

MATLAB + Mex + OpenCV: Links and compiles correctly but can't find library at run time
I encountered a similar problem some days ago. This problem only happens when you using the matlab remotely on a cluster. Editing the LD_LIBRARY_FILE in Matlab is useless, and I don't know why. I solved the problem by defining the LD_LIBRARY_PATH in .bashrc (or .bash_profile).

Categories : C++

Is conversion from OpenCV code to FPGA code is easier than Matlab code or not?
Firstly - why do you want to use an FPGA? Unless you have to for good reasons, avoid it! Good reasons can be things like: cost power size pre-existing hardware which must be re-used personal interest it's an assignment where FPGAs are mandated Bad reasons include "image-processing... that must mean I need an FPGA!" Think FPGA If you want to implement on FPGA you need to think "FPGA" right from the beginning. They have very particular characteristics compared to conventional processors, which means that many "conventional" algorithms are very difficult to implement efficiently on FPGAs. And other algorithms which conventional processing will struggle with can actually be done quite simply on an FPGA. One classic (non-image) example is CRC calculation, which is often implemented

Categories : Matlab

OpenCV Error: Assertion failed (ptnum > 3) in unknown function, file (Java + opencv 2.4.6)
I think the problem lies in the number of points in your convex hull. It should have at least 3 points to make using the convexityDefect() possible. It can easily be checked using an if in the for loop: if(hull_.rows() >= 3){ Imgproc.convexityDefects(contours.get(0), hull_, convexityDefects); }

Categories : Java

opencv libraries precompiled for javacv opencv android project
It will take a little more effort to "run this code" correctly. In short, JavaCV is a wrapper on top of OpenCV, and you have to compile the OpenCV and correctly move all the shared libraries (.so) to your Android development project etc. Like the original article suggested, you need to go to JavaCV homepage and read the installation instructions.

Categories : Android

How do I find out in the OpenCV C Inerface,...In what .so a OpenCV function is defined
You need to look into http://docs.opencv.org. If you were to try and locate the Sobel function for instance, you would see that the documentation path is (at the top of the webpage OpenCV 2.4.6.0 documentation » OpenCV API Reference » imgproc. Image Processing) So the corresponding module is imgproc. You can use this to locate into which module your functions are

Categories : C

OpenCV+Eclipse+Android: Error org.opencv.video Video.java
If someone have this problem, do this: In OpenCV project.properties change target=android-11 (or in some cases 14) to target=android-17. Edit: For the newer OpenCV-2.4.10-android-sdk you will need to change it to target=android-20.

Categories : Java

Will Matlab standalone be faster than Matlab from UI for long execution code?
Applications built with MATLAB Compiler should execute at pretty much exactly the same speed as within MATLAB. MATLAB Compiler does not convert your MATLAB code into machine code in the same way as a C compiler does for C. What it does is to archive and encrypt your MATLAB code (note, it properly encrypts it, not just pcodes it as a comment suggests), create a thin executable wrapper and package them together, possibly also with MATLAB Compiler Runtime (MCR). MCR is very similar to MATLAB itself, without a graphical user interface, and is freely redistibutable. When you run the executable, it dearchives and decrypts your MATLAB code and runs it against the MCR. It should run exactly the same, both in terms of results and speed. Very old versions of MATLAB Compiler (pre-version 4.0) work

Categories : Matlab

Launching Matlab from java ProcessBuilder, Matlab console doesn't appear in Mac OS 10.8
You need to specify that MATLAB is to run with a visible UI by making use of the -desktop flag. I don't believe this is documented. So the command you need to run is matlab -desktop -r "initMatlab;runJavaUI;" I've created a Java library called matlabcontrol that can abstract all of this away from you. It can launch MATLAB while running on Windows, OS X, and Linux and then allow you to interact with MATLAB via eval and feval commands. matlabcontrol's code to launch MATLAB is located in matlabcontrol.RemoteMatlabProxyFactory's createProcess(...) method. If you make use of matlabcontrol as a Java library you won't directly interact with either this class or this method.

Categories : Java

How to apply a trained Matlab neural network from C++ without call to Matlab?
Of course it is possible - neural networks are clear mathematical models. All you need is a compatible representation, where you have stored: network topology (number of neurons in particuluar layers) network weights (between all neurons) network activation functions (for each neuron) And that's all. The exact solution depends on what matlab library you are using for neural networks. There is a "standard" for prediction models called PMML, which can be loaded by for example Weka libraries. Either way - it is easy operation, so you can also implement it by hand by simply storing all the numbers in the text file and simulating network in the C++ (as the "forward" phase of the neural network is just few lines of code - the training part is the long one).

Categories : C++

Matlab: Improper index matrix reference (or outsmarting matlab)
In the latest versions of MATLAB (13a/13b) there's a unit testing framework built in that looks very similar to what you're attempting. Instead of expect(myfibonacci(0)).toBe(0); you would write import matlab.unittest.constraints.IsEqualTo testCase.verifyThat(myfibonacci(0), IsEqualTo(0)) (You could also/instead have assumeThat, assertThat, or fatalAssertThat). If for some reason you wish to implement your own framework, note the small difference in your syntaxes - you have a dot whereas MathWorks have a comma between myfibonacci(0) and the test condition. In MATLAB you can't index into the result of a subscripted expression like that (well, you could, but you would have to overload subsref, and that's a world of pain, trust me). So the way they've done it is to introduce the test

Categories : Matlab

Run Matlab executable file with MATLAB Compiler Runtime (MCR)
It simply means that you don't have rights to run PROGRAM. What is the output of the command: ls -l PROGRAM ? Maybe you've compiled this program as a root? Try to change the access using chmod.

Categories : Matlab

MATLAB: checkmark in MATLAB figure with LaTeX interpreter
it's not pretty, but might be good enough: xlabel('$surd$','interpreter','latex') or look here for other things that look like a tick http://detexify.kirelabs.org

Categories : Matlab

MATLAB - What are the units of Matlab Camera Calibration Toolbox
I know next to nothing about matlabs (not entirely true but i avoid matlab wherever I can, and that would be almost always possible) tracking utilities but here's some general info. Pixel dimension on the sensor has nothing to do with the size of the pixel on screen, or in model space. For all purposes a camera produces a picture that has no meaningful units. A tracking process is unaware of the scale of the scene. (the perspective projection takes care of that). You can re insert a scale by taking 2 tracked points and measuring the distance between those points. This is the solver spaces distance is pretty much arbitrary. Now if you know the real distance between these points you can get a conversion factor. By doing: real distance / solver space distance. There's really now way to kno

Categories : Matlab

MatLab-->csv: Export data to csv file using dlmwrite in Matlab
I think the problem is that you write the names to a file at the local folder and not the other folder. fldr = fullfile('c:','Data_Analysis'); nomFile=fullfile( fldr, 'Test.csv' ); fid=fopen(nomFile,'w'); fprintf(fid,'%s,',names{:}); fprintf(fid,' '); dlmwrite(nomFile,A,'-append'); fclose(fid);

Categories : Matlab

Conversion of opencv C++ code to Python opencv code
As Abid commented, I would use cv2 rather than cv module. Since cv2 is based on c++ interface, you can develop scripts with fewer lines of code assuming you can do OOP. Another advantage of using cv2 is that python statement is mostly analogous to its c++ statement drawing2 = cv2.absdiff(drawing,drawing0) sc = cv2.sumElems(drawing2) ar = sc[0] + sc[1] + sc[2] More details are here

Categories : C++

Matlab density plot, Heat map, Matlab
You can control the colour of each point like so: scatter(x1, y1, [], C) where C is the same size as your x1 and y1 matrices. Now if you describe the rules of how you want this heatmap colour modulation to happen, we can help you construct C from x1 and y1...

Categories : Matlab

How to get the Matlab workspace associated with the current Matlab project in C#?
I have already the solution, the way is the next: Create a .m file (for example SaveWorskpace.m) con this information: save test.mat Add SaveWorskpace.m at the project with Matlab Compiler Deployment Tool. Compile the project with Matlab Compiler Deployment Tool Add reference at the c# project Call function SaveWorkspace() Ready, you have variables save in the workspace test.mat

Categories : C#

Call matlab from c++ using VS2010 and matlab 2007a
This is probably very late reply but this sample code of mine may help you. #include<iostream> #include<math.h> #include<engine.h> #pragma comment (lib, "libmat.lib") #pragma comment (lib, "libmx.lib") #pragma comment (lib, "libmex.lib") #pragma comment (lib, "libeng.lib") using namespace std; const int N = 9; //Number of grid points int main() { // start matlab engine Engine *ep = engOpen(NULL); if (!(ep = engOpen(""))) { fprintf(stderr, " Can't start MATLAB engine "); return EXIT_FAILURE; } int i, j; // Grid creation with aspect ratio r double sum_r = 0, r = 1; for (i = 0; i < N-1; i++){ sum_r += pow(r,i); } double dx0 = 1 / sum_r; // calculate first dx double dy0 =

Categories : C++

How to use Matlab from JAVA without using the Matlab Compiler
If you have Matlab (but you don't have builderJA) then you can use matlabcontrol for using matlab functions in java.(There might be other alternatives too, but I don't know) If you don't have Matlab at all then you can "create the java version of the matlab function" in some other computer having Matlab and builderJA installed, and use the jar files in your own computer. You only need to have MCR (Matlab Compiler Runtime- Its FREE) installed on your computer. Strickly answering your question: Is there a way to do use Matlab from JAVA, but without the need to have the Matlab Compiler? The answer is: Yes, you can use it. Using matlabcontrol (A java API to interact with Matlab).

Categories : Java

compile a matlab gui for win 32 system using 64 bit win and MATLAB
As far as I know you cannot actually use 64 bit matlab to build a 32 bit program. When I faced the same situation, Mathworks recommended me to (also) install 32 bit matlab on my 64 bit windows. I did not try it, but that should allow you to build 32 bit programs again.

Categories : Matlab

MATLAB Compiler vs MATLAB Coder
I'm not an expert, but the Coder is described as generating standalone C/C++ code, making no mention of the MCR. I notice however that it says that it only supports a "subset" of the Matlab language, which you can read more about here. The Compiler appears to just package up your Matlab code as you suggested, so probably supports most features.

Categories : Matlab

Converting MATLAB 'imagesc' function to work with R's 'imagesc' from R's 'matlab' library
As I read the question and the linked material and some other material found with Google, you want the combined capacities of the image and axis functions in R. Some of the other material said that imagesc really only relabels the axis annotation. (And it has some additional color scaling capacity that you don't seem to be requesting.) Reading images in from files may take some extra packages. There is a grImport package with useful capabilities for pdf. There are also packages that specialize in particular formats, eg. tiff or rtiff. If you have a modes sized matrix to plot, you should offer dput(mat). In the absence of an example and specific directions can offer this adaptation of an example in the middle of the Examples section of ?image. > image(t(volcano)[ncol(volcano):1,]) #

Categories : R

AAM and ASM with opencv 2.4.3
You can get AAM and ASM code in vosm library but this is not the best way to find face ROI. Haar cascades much better for this task. AAM and ASM usually used for finding facial feature points, and they need already defined face region. Another ASM code you can find here: https://github.com/MasteringOpenCV/code (see chapter 6).

Categories : Opencv

Qt with OpenCv does nothing
I'm not sure, if this will help you, but lets give a try... First, in my programs I use the bars '/' instead of '\'. Second I never put .dll at libs. I use something like this: LIBS += -LC:/OpenCV/lib/ -llibopencv_core245 -llibopencv_highgui245 -llibopencv_imgproc245 Try to do those changes and then 'run qmake' and 'rebuild all', if you are using the qtcreator.

Categories : C++

getting ROI in OpenCV
You have the coordinates of the 4 corners of the distorted chessboard. Use these to find the equations for the 4 lines that form the quadrilateral. For any given point, you will then be able to check if it lies between the top and bottom lines and between the left and right lines. If it does, mark it as 1 on a mask image, else 0. Use the mask image to cut out the distorted region.

Categories : C++

OpenCV RTP Decoding
you will need an RTP depayloader for your specific stream. RTP (being targeted at UDP - that is: packet oriented protocols) does not have a 1:1 mapping between packets (as transmitted) and frames. most of the time, a single frame will be transmitted via several packets (an ethernet frame (not to be confused with your image frame) is usually limited to about 1500 bytes, which makes only tiny images...) splitting and reassambling your payload chunks into/from network packets is the task of the RTP payloader resp. depayloader. the easiest way to do this is probably via gstreamer, which already provides (de)payloaders for h.264

Categories : C++

opencv - rgb value keeps changing
I am not sure how did you achieve type casting from IplImage to int int total = (int)(blue[i]) + (int)(green[i]) + (int)(red[i]); but you certainly need to use pixel by pixel summation for each channel (not image by image) to find the overall values.

Categories : C++

Qt4 or Qt5 (mingw) and openCV 2.4.6
I managed to configure a Qt Creator project with OpenCV to run a simple OpenCV application I wrote recently, named cvDisplacementMapFilter. I tested it with OpenCV 2.4.7 on Mac OS X 10.7.5 and OpenCV 2.4.2 on Windows 7. I believe the following .pro file can help you: SOURCES += main.cpp # On my system I have to specify g++ as compiler else it will use clang++ by default QMAKE_CXX=g++ QMAKE_CC=gcc ## OpenCV settings for Unix/Linux unix:!mac { message("* Using settings for Unix/Linux.") INCLUDEPATH += /usr/local/include/opencv LIBS += -L/usr/local/lib/ -lopencv_core -lopencv_highgui -lopencv_imgproc } ## OpenCV settings for Mac OS X macx { message("* Using settings for Mac OS X.") INCLUDEPATH += /usr/local/include/opencv LIBS +=

Categories : Qt

OpenCV C++ to C conversion
It seems like porting C++ program to C. As per Wikipedia, there are C interfaces which you can look for your purpose. Declarations seems right provided the parameters are not reference but pointers since C does not support reference. You can use pointers to wrap the class objects. It will be like: CvMat * cv2dRotationMatrix( CvPoint *, CvAngle *, float ); As you have pointed out that you need to wrap C++ functions under a pure C function.

Categories : C++

OpenCV = operator
It explains in the link you provided. Mat& Mat::operator = (const Mat& m) m :The assigned, right-hand-side matrix. Matrix assignment is O(1) operation, that is, no data is copied. Instead, the data is shared and the reference counter, if any, is incremented. Before assigning new data, the old data is dereferenced via Mat::release .

Categories : C++

OpenCV and convexityDefects
So i found the answer i was looking for..... The libraries i used to compile my project where in wrong location. so i used pkg-config --libs --cflags opencv to find exactly where are my libs.... After that i included these libraries in Code-Blocks and everything magicly started to work.

Categories : C++

Is there a way to disable TBB in openCV?
Try setNumThreads(0), or for a more thorough solution, try recompiling the libraries as described here.

Categories : Opencv



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.