2020-08-10 07:32:12 -0600
| received badge | ● Popular Question
(source)
|
2019-08-02 00:32:25 -0600
| received badge | ● Famous Question
(source)
|
2017-12-25 00:45:56 -0600
| received badge | ● Notable Question
(source)
|
2017-12-18 02:05:16 -0600
| received badge | ● Notable Question
(source)
|
2016-04-07 15:17:28 -0600
| received badge | ● Popular Question
(source)
|
2015-10-21 16:41:04 -0600
| received badge | ● Notable Question
(source)
|
2015-05-26 21:44:33 -0600
| received badge | ● Popular Question
(source)
|
2015-03-28 12:07:34 -0600
| received badge | ● Student
(source)
|
2014-12-09 13:41:23 -0600
| marked best answer | Opencv Resize memory leak I am using the cv::resize function from opencv (2.4.3). I am getting a memory leak. This it the code: Mat src(height_,width_,CV_8UC3,(void *)&bits_[0]);
cv::resize(src, src,cv::Size(width,height));
BMPImage result (src);
src.release();
src = NULL;
I have a memory leak in cv::resize... This code is used a lot of times (It resizes hundred images in an execution) and the memory doesn't stop to increase.... I was checking the opencv documentation but It explains that cv::resize handles its memory... In my log, it get the error from the deallocation: 0x22081 call 0x6118 <?deallocate@?$AutoBuffer@E$0BAAI@@cv@@QAEXXZ>
Update I fixed the memory leak problem.... with this code Mat src(height_,width_,CV_8UC3,(void *)&bits_[0]);
Mat dst;
cv::resize(src, dst,cv::Size(width,height),0,0,INTER_CUBIC);
BMPImage result (dst);
src.release();
dst.release();
src = NULL;
dst = NULL;
This code doesn't fix the deallocation problem with it is related to: src.release();
src = NULL;
If I have a moment, I will investigate it. |
2014-10-21 05:44:27 -0600
| received badge | ● Popular Question
(source)
|
2014-10-16 04:46:22 -0600
| asked a question | Executing hello-android I am trying to reuse the example hello-android with my source code. I copied all my source files (*h and *cpp) in the sample folder (samples/android/hello-android) but i had problems... This is the example cmake_android.sh script #!/bin/sh
cd `dirname $0`
BUILD_DIR=build_armeabi
opencv_android=`pwd`/../../../android
opencv_build_dir=$opencv_android/$BUILD_DIR
mkdir -p $BUILD_DIR
cd $BUILD_DIR
RUN_CMAKE="cmake -DOpenCV_DIR=$opencv_build_dir -DARM_TARGET=armeabi -DCMAKE_TOOLCHAIN_FILE=$opencv_android/android.toolchain.cmake .."
echo $RUN_CMAKE
$RUN_CMAKE
It didn't find the toolchain file.... The opencv_android seems incorrect, I think it should be somethink like: opencv_android=pwd /../../../platforms/android.... I have fixed this (changed the opencv_android variable)... But I am having problems yet. cmake -DOpenCV_DIR=/home/carlos/Desktop/tools/opencv-2.4.9/samples/android/hello-android/../../../android/build_armeabi -DARM_TARGET=armeabi -DCMAKE_TOOLCHAIN_FILE=/home/carlos/Desktop/tools/opencv-2.4.9/samples/android/hello-android/../../../android/android.toolchain.cmake ..
CMake Error at /usr/share/OpenCV/OpenCVConfig.cmake:45 (include):
include could not find load file:
/usr/share/OpenCV/OpenCVModules_armeabi.cmake
Call Stack (most recent call first):
CMakeLists.txt:22 (FIND_PACKAGE)
Ideas? does someone know if i fixed correctly the cmake_android script?? |
2014-10-03 09:15:11 -0600
| asked a question | Pass cv2.Mat (python) object to cv::Mat (c++) with SWIG I am trying to pass from Python a cv2 Mat object to my SWIG wrapper for C++. My module in C++ is this:. #ifndef SYMBOL_TRACKER
#define SYMBOL_TRACKER
#include <string>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <memory>
#include <cmath>
#include "core.h"
#include "symbol_descriptor.h"
#include "symbol_matcher.h"
namespace cvc {
class SymbolTracker: public core::Tracker {
private:
/* load configuration */
void loadConfiguration();
void initialization();
public:
SymbolTracker(std::vector<std::string> modelImageFiles
,std::string orbFile_=cvc::ORB_FILE
,std::string flannFile_=cvc::FLANN_FILE) ;
core::ResultResponse process(cv::Mat & colorFrame, cv::Mat & grayFrame);
};
}
#endif
the SWIG file: /* File : tracker.i */
%module symbol_tracker
%include "std_string.i"
%include "std_vector.i"
namespace std {
%template(vectors) vector<std::string>;
};
%{
#include "symbol_tracker.h"
%}
/* Let's just grab the original header file here */
/*%include "core.h" */
%include "core.h"
%include "symbol_tracker.h"
And the python script to test the wrapper: #!/bin/sh
import symbol_tracker
import numpy as np
import cv2
img = cv2.imread('test_resources/model_image.bmp')
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
listModels = symbol_tracker.vectors()
listModels.push_back(symbol_tracker.MODEL_IMAGE_FILE)
tracker = symbol_tracker.SymbolTracker(listModels,symbol_tracker.ORB_FILE,symbol_tracker.FLANN_FILE)
grayImage = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
response = tracker.process(img,grayImage)
I get an error to use an incompatible argument: Traceback (most recent call last):
File "symbol_tracker_test.py", line 17, in <module>
response = tracker.process(img,grayImage)
TypeError: in method 'SymbolTracker_process', argument 2 of type 'cv::Mat &'
But I don't know how I could parse my grayImage and img argument in order to call correctly the function... |
2014-09-12 05:12:05 -0600
| received badge | ● Citizen Patrol
(source)
|
2014-09-12 04:36:22 -0600
| commented question | Error copying Mat object with Android Thanks @berak, yes, it was duplicated :( |
2014-09-12 04:29:35 -0600
| asked a question | Error copying Mat object with Android I am using the class JavaCameraVIew and CvCameraViewListener2 for a Android application. With these classe, i am trying to get each frame and analyze it but my application works a few minutes and crashes with these errors: W/InputMethodManagerService( 765): Session failed to close due to remote exception
W/InputMethodManagerService( 765): android.os.DeadObjectException
W/InputMethodManagerService( 765): at android.os.BinderProxy.transact(Native Method)
W/InputMethodManagerService( 765): at com.android.internal.view.IInputMethodSession$Stub$Proxy.finishSession(IInputMethodSession.java:292)
...
..
.
D/mm-camera( 199): module_faceproc_client_schedule_mode:1808] apply 2 report 1 new_mode 0
D/JavaCameraView( 2412): Preview Frame received. Frame size: 1843200
D/CameraBridge( 2412): mStretch value: 1.125
D/mm-camera( 199): module_faceproc_client_schedule_mode:1808] apply 3 report 2 new_mode 0
D/JavaCameraView( 2412): Preview Frame received. Frame size: 1843200
D/CameraBridge( 2412): mStretch value: 1.125
...
..
.
W/CameraService( 186): Disconnecting camera client 0xb74c2f88 since the binder for it died (this pid 186)
E/Surface ( 186): queueBuffer: error queuing buffer to SurfaceTexture, -32
E/Camera3-OutputStream( 186): returnBufferCheckedLocked: Stream 0: Error queueing buffer to native window: Broken pipe (-32)
E/Camera3-Device( 186): Can't return buffer 1 for frame 197 to its stream: Broken pipe (-32)
E/Surface ( 186): queueBuffer: error queuing buffer to SurfaceTexture, -32
...
I could find the error but i don't know how i should fix it .... The error is if i want to copy a frame in order to apply another operations... My main Activity.java is: public class TrackerActivity extends Activity implements CvCameraViewListener2 {
private JavaCamResView openCVCameraView;
public TrackerActivity() {
Log.i(TAG, "Instantiated new " + this.getClass());
appContext = (new AppContextFactory()).create();
}
...
..
.
@Override
public Mat onCameraFrame(CvCameraViewFrame frame) {
Mat outputFrame = outputFrame = frame.rgba().clone(); <- the ERROR is here....
return outputFrame;
}
Is it normal that i can not copy input frames..? In my opinion, it shouldn't be a problem.... Furthermore, Does somebody know how i could do to fix this error? I didn't add all the stacktrace and classes because it can be tedious, but i uploaded in a pastebin web: http://pastebin.com/PLSaEAbj http://pastebin.com/iwwNG3Ln http://pastebin.com/G9zvwbMZ |
2014-09-12 04:28:05 -0600
| asked a question | Error copying Mat object with Android I am using the class JavaCameraVIew and CvCameraViewListener2 for a Android application. With these classe, i am trying to get each frame and analyze it but my application works a few minutes and crashes with these errors: W/InputMethodManagerService( 765): Session failed to close due to remote exception
W/InputMethodManagerService( 765): android.os.DeadObjectException
W/InputMethodManagerService( 765): at android.os.BinderProxy.transact(Native Method)
W/InputMethodManagerService( 765): at com.android.internal.view.IInputMethodSession$Stub$Proxy.finishSession(IInputMethodSession.java:292)
...
..
.
D/mm-camera( 199): module_faceproc_client_schedule_mode:1808] apply 2 report 1 new_mode 0
D/JavaCameraView( 2412): Preview Frame received. Frame size: 1843200
D/CameraBridge( 2412): mStretch value: 1.125
D/mm-camera( 199): module_faceproc_client_schedule_mode:1808] apply 3 report 2 new_mode 0
D/JavaCameraView( 2412): Preview Frame received. Frame size: 1843200
D/CameraBridge( 2412): mStretch value: 1.125
...
..
.
W/CameraService( 186): Disconnecting camera client 0xb74c2f88 since the binder for it died (this pid 186)
E/Surface ( 186): queueBuffer: error queuing buffer to SurfaceTexture, -32
E/Camera3-OutputStream( 186): returnBufferCheckedLocked: Stream 0: Error queueing buffer to native window: Broken pipe (-32)
E/Camera3-Device( 186): Can't return buffer 1 for frame 197 to its stream: Broken pipe (-32)
E/Surface ( 186): queueBuffer: error queuing buffer to SurfaceTexture, -32
...
I could find the error but i don't know how i should fix it .... The error is if i want to copy a frame in order to apply another operations... My main Activity.java is: public class TrackerActivity extends Activity implements CvCameraViewListener2 {
private JavaCamResView openCVCameraView;
public TrackerActivity() {
Log.i(TAG, "Instantiated new " + this.getClass());
appContext = (new AppContextFactory()).create();
}
...
..
.
@Override
public Mat onCameraFrame(CvCameraViewFrame frame) {
Mat outputFrame = outputFrame = frame.rgba().clone(); <- the ERROR is here....
return outputFrame;
}
Is it normal that i can not copy input frames..? In my opinion, it shouldn't be a problem.... Furthermore, Does somebody know how i could do to fix this error? I didn't add all the stacktrace and classes because it can be tedious, but i uploaded in a pastebin web: http://pastebin.com/PLSaEAbj http://pastebin.com/iwwNG3Ln http://pastebin.com/G9zvwbMZ |
2014-02-07 10:40:38 -0600
| commented question | Error to configure android_test project Sorry @berak, i didn't know if i did something wrong when i configured the project, or it is the project in the repository which it is not well-configured (the extra steps which I did they are not explained in the tutorial....), my apologies if i was not clear... |
2014-02-07 10:31:18 -0600
| commented question | Error to configure android_test project I deleted the tests with errors and include mine , it seems that it is working now. |
2014-02-07 09:13:24 -0600
| asked a question | Error to configure android_test project Hello all, I am trying to configure a project to test my Opencv application in Android, but I follow necessary steps from this web but i get error to import the project how it is specified in the web.... My error is this: 2014-02-07 15:34:28 - android_test] Project has no project.properties file! Edit the project properties to set one.
[2014-02-07 15:56:08 - android_test] Project has no project.properties file! Edit the project properties to set one. I understand i need a project.properties file, but I don't why it is not included in the opencv repository... and why it is not explained in the tutorial, am i doing something wrong? P.D:
Manually, i added this file, and i could import the project but i get errors in some tests... |
2013-11-15 07:30:33 -0600
| commented question | OpenCV and Intel IPP prebuild-libs Thanks @berak, I will try this |
2013-11-15 04:10:50 -0600
| asked a question | OpenCV and Intel IPP prebuild-libs Hi, I has finished to implement a project with OpenCV and I would be interested in add Intel IPPs.
I was checking the OpenCV web to know possible ways to do this, i found: 1) Compiles the OpenCV source with cmake and with necessary flags. (I would rather not do this...) 2) Downloads a OpenCV prebuild-lib version (It was commented in this link) Also,I read OpenCV can check if there are installed the Intel IPPs (there are dlls in its path) and use it (I can't find the link where I read this...) I have a few questions... Can OpenCV load automatically Intel IPPs? How can I do this? Where can I find this OpenCV prebuild-lib version which uses IPPs? Finally, I check if the project loads these IPPs libraries in my project with this code: int main(){
int NumUploadedFunction = 0;
NumUploadedFunction = cv::useOptimized();
printf("\t NumUploadedFunction = %d \n\n", NumUploadedFunction);
const char* opencv_lib = 0;
const char* add_modules = 0;
cvGetModuleInfo(0, &opencv_lib,&add_modules);
printf("\t opencv_lib = %s,\n\t add_modules = %s\n\n", opencv_lib,add_modules);
}//_end_of_file_
but It only prints the opencv core module, I don't know if it works correctly. |
2013-10-15 11:27:21 -0600
| asked a question | Error DataDepth with Mat_<compObj> Hello, I am trying to create this data structure in OpenCV: typedef Vec2f ScalarComplex;
typedef Vec<ScalarComplex,32> CellPlane;
typedef cv::Mat_<CellPlane> Plane;
But when I try to declare a variable: Plane plane
It throws this error: error : class "cv::DataDepth<ScalarComplex>" has no member "value"
error : class "cv::DataDepth<ScalarComplex>" has no member "fmt"
I think it can't know the depth for the 'ScalarComplex' type but I don't know why because it is a
defined OpenCV type. I was trying to fix it with std:vector (It is possible) but I would prefer to use OpenCV types to get profit from its features and undertand what it is happening .... |
2013-10-05 05:28:30 -0600
| received badge | ● Necromancer
(source)
|
2013-10-05 05:28:30 -0600
| received badge | ● Self-Learner
(source)
|
2013-10-03 18:10:57 -0600
| answered a question | matlab gradient() to C++ I implemented a custom function to not use the Sobel operation and emulate the gradient operation, it works: pair<Mat,Mat> gradient(Mat & img, float spaceX, float spaceY) {
Mat gradY = gradientY(img,spaceY);
Mat gradX = gradientX(img,spaceX);
pair<Mat,Mat> retValue(gradX,gradY);
return retValue;
}
/// Internal method to get numerical gradient for x components.
/// @param[in] mat Specify input matrix.
/// @param[in] spacing Specify input space.
static Mat gradientX(Mat & mat, float spacing) {
Mat grad = Mat::zeros(mat.cols,mat.rows,CV_32F);
/* last row */
int maxCols = mat.cols;
int maxRows = mat.rows;
/* get gradients in each border */
/* first row */
Mat col = (-mat.col(0) + mat.col(1))/(float)spacing;
col.copyTo(grad(Rect(0,0,1,maxRows)));
col = (-mat.col(maxCols-2) + mat.col(maxCols-1))/(float)spacing;
col.copyTo(grad(Rect(maxCols-1,0,1,maxRows)));
/* centered elements */
Mat centeredMat = mat(Rect(0,0,maxCols-2,maxRows));
Mat offsetMat = mat(Rect(2,0,maxCols-2,maxRows));
Mat resultCenteredMat = (-centeredMat + offsetMat)/(((float)spacing)*2.0);
resultCenteredMat.copyTo(grad(Rect(1,0,maxCols-2, maxRows)));
return grad;
}
/// Internal method to get numerical gradient for y components.
/// @param[in] mat Specify input matrix.
/// @param[in] spacing Specify input space.
static Mat gradientY(Mat & mat, float spacing) {
Mat grad = Mat::zeros(mat.cols,mat.rows,CV_32F);
/* last row */
const int maxCols = mat.cols;
const int maxRows = mat.rows;
/* get gradients in each border */
/* first row */
Mat row = (-mat.row(0) + mat.row(1))/(float)spacing;
row.copyTo(grad(Rect(0,0,maxCols,1)));
row = (-mat.row(maxRows-2) + mat.row(maxRows-1))/(float)spacing;
row.copyTo(grad(Rect(0,maxRows-1,maxCols,1)));
/* centered elements */
Mat centeredMat = mat(Rect(0,0,maxCols,maxRows-2));
Mat offsetMat = mat(Rect(0,2,maxCols,maxRows-2));
Mat resultCenteredMat = (-centeredMat + offsetMat)/(((float)spacing)*2.0);
resultCenteredMat.copyTo(grad(Rect(0,1,maxCols, maxRows-2)));
return grad;
}
|
2013-10-03 18:04:54 -0600
| answered a question | "Not-a-Number" NaN with arithmetical operations It is the expected behavior and i couldn't change it. I replaced to the values with NaN manually.... |
2013-07-26 06:12:24 -0600
| asked a question | "Not-a-Number" NaN with arithmetical operations Hello, I have a doubt. I am doing a division between two vectors (65356x1 size). Both vectors include 0s and It divides each array element. The problem is when it divides by 0s, operation (0/0), its result is not NaN, is 0!. I think It is wrong... Are there some way to get the correct result (with NaNs)? The code is very simple: Mat G = im_g/tableReshaped; (where img_g and tableReshaped are 65356x1 matrices). |
2013-07-10 04:48:44 -0600
| marked best answer | Implement imfilter(matlab) with OpenCV Hello, I am trying to port matlab code to c++ with opencv. I could import most source code but I had serious problems with the imfilter function. I was trying to use the filter2d function for c++, but It doesn't get same results between themselves. What is the difference? How I could get the same result? The source code is very simple..... //src_gray has one channel
//C++ code
filter2D(src_gray, dst,-1, kernel);
//Matlab code
dst = imfilter(src_gray,kernel)
Inputs:
src_gray= 11 11 11 11 11
11 11 11 11 11
kernel = 2 2
2 2
output: Matlab: ans = 88 88 88 88 44
44 44 44 44 22
C++: [88 88 88 88 88; 88 88 88 88 88]
My c++ code: /// Initialize arguments for the filter
Point anchor( -1, -1 );
double delta = 0;
int ddepth = -1;
Mat dst;
float data[2][5] = {{11,11,11,11,11},{11,11,11,11,11}};
float kernel[2][2] = {{2,2},{2,2}};
Mat src = Mat(2, 5, CV_32FC1, &data);
Mat ker = Mat(2, 2, CV_32FC1, &kernel);
filter2D(src, dst, ddepth , ker,anchor);
cout << dst << endl;
|
2013-07-09 08:27:15 -0600
| edited question | matlab gradient() to C++ Hello, I am trying to port the method gradient (Matlab) to C++ with OpenCV: I tested this in matlab: Input: A =
1 3
4 2
[dx dy] = gradient(A, 4, 4)
Output: dx =
0.5000 0.5000
-0.5000 -0.5000
dy =
0.7500 -0.2500
0.7500 -0.2500
I followed this example : And I implemented this code: float A[2][2] = {{1.0,3.0},{4.0,2.0}};
Mat src_grad = Mat(2,2,CV_32F,A);
Mat grad_x, grad_y;
Mat abs_grad_x, abs_grad_y;
Mat grad;
/// Gradient X
Sobel( src_grad, grad_x, CV_32F, 1, 0);
convertScaleAbs( grad_x, abs_grad_x );
/// Gradient Y
Sobel( src_grad, grad_y, CV_32F, 0, 1);
convertScaleAbs( grad_y, abs_grad_y );
/// Total Gradient (approximate)
addWeighted( abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad );
But grad doesn't have the same result. The problem is in the gradient method and its second and third parameter ( gradient(A,4,4)) which specify the 'spacing'. Is it correct this code? How I can specify this spacing in this example? Update gradient(A,4,4). These 4s are used to specify the kernel size to calculate the derivative for each number. It was returning matrices with values to 0. I tested a matrix 3x3 (because Sober works with a ksize=3) and now, I returns values !=0... |