Hi,
I'm beginner in using TAPI for OpenCV and right now I'm trying to write a custom OpenCL kernel for output matrices of type CV_32F. I tried to isolate the problem in a small program but for some reason, I get a very different assert message there. Anyways, something is seriously wrong with my approach. This is my C++ code:
std::string code;
std::ifstream fileStream( "test.cl" );
size_t size = 0;
fileStream.seekg( 0, std::ios::end );
size = fileStream.tellg();
fileStream.seekg( 0, std::ios::beg );
code.resize( size );
fileStream.read( &code[0], size );
fileStream.close();
::cv::String errorMsg;
::cv::ocl::ProgramSource source( code );
::cv::ocl::Kernel kernel( "test", source, "", &errorMsg );
if( errorMsg.size() )
throw std::runtime_error( errorMsg );
cv::UMat src( cv::Size( 640, 480 ), CV_8UC1 );
cv::UMat dst( cv::Size( 640, 480 ), CV_32FC1 );
//fill image...
cv::ocl::KernelArg srcarg = cv::ocl::KernelArg::ReadOnlyNoSize( src, src.channels() );
cv::ocl::KernelArg dstarg = cv::ocl::KernelArg::WriteOnly( dst, dst.channels() );
// pass 2 arrays to the kernel and run it
size_t globalThreads[3] = { (size_t) src.cols, (size_t) src.rows, 1 };
if( !kernel.args( srcarg, dstarg ).run( 2, globalThreads, NULL, false ) )
std::cerr << "executing kernel failed" << std::endl;
else
{
std::cout << "SUCCESS!" << std::endl;
cv::imshow( "src", src );
cv::imshow( "dst", dst );
cv::waitKey();
}
My cl file looks like this:
__kernel void test(
__global const uchar *srcptr, int src_step, int src_offset,
__global float *dstptr, int dst_step, int dst_offset, int dst_rows, int dst_cols
)
{
int x = get_global_id(0);
int y = get_global_id(1);
if (x < dst_cols && y < dst_rows)
{
int src_index = mad24(y, src_step, mad24(x, sizeof(uchar), src_offset));
int dst_index = mad24(y, dst_step, mad24(x, sizeof(float), dst_offset));
__global const uchar *src = (__global const uchar*)(srcptr + src_index);
__global float* dst = (__global float*)(dstptr + dst_index);
dst[0] = 1.0f - src[0] / 255.0f;
}
}
The output this gives me is the following:
> SUCCESS!> OpenCV Error: Assertion failed (clEnqueueReadBuffer(q, (cl_mem)u->handle, CL_TRUE, 0, u->size, alignedPtr.getAlignedPtr(), 0, 0, 0) == CL_SUCCESS) in cv::ocl::OpenCLAllocator::map, file C:\build\master_winpack-build-win64-vc14\opencv\modules\core\src\ocl.cpp, line 4773>OpenCV Error: Assertion failed (u->refcount == 0 && "UMat deallocation error: some derived Mat is still alive") in cv::ocl::OpenCLAllocator::deallocate, file C:\build\master_winpack-build-win64-vc14\opencv\modules\core\src\ocl.cpp, line 4528
When I change float to uchar in the CL code and CV_32FC1 to CV_8UC1, it works. I tried to orient on CL code of the OpenCV core, however I could not find any samples for writing float data in CL kernels in the OpenCL source code. Which is weird since you do have to deal with floating point data, don't you? But all your kernels, e.g. in opencl_kernels_core.cpp use uchar* desptr as an argument.
1) Why are there no float implementations?
2) How would I create a kernel writing float data?
Thanks!
↧
Writing custom OpenCL kernel for CV_32F matrices
↧
Template matching with multiple template
hi , I am working on a robotic project which require template matching,the problem i facing is I need to compare one image with multiple template which store inside a folder but I am new in python and i not sure how to do it, is anyone can help me to resolve this problem? thanks
import cv2
import numpy as np
from matplotlib import pyplot as plt
img_rgb = cv2.imread('image.jpg')
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
##template = ( i need to read multiple template here)
w, h = template.shape[::-1]
res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)
threshold = 0.8
loc = np.where( res >= threshold)
for pt in zip(*loc[::-1]):
cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,0,255), 2)
cv2.imshow('Detected',img_rgb)
↧
↧
I was able to open ids camera the code in visual studio 2012 with opencv 2.4.13,but now it can't open in visual studio 2015 opencv 3.2.0,c++.pls help me with a solution
#include
#include
using namespace cv;
using namespace std;
int main()
{
Mat CameraFrame;
Mat Grey;
VideoCapture cap;
char keypressed;
//Opens the first imaging device.
cap.open(0);
//Check whether user selected camera is opened successfully.
if( !cap.isOpened() )
{
cout << "***Could not initialize capturing...***\n";
return -1;
}
//Create a windows to display camera preview.
namedWindow("Camera Preview", CV_WINDOW_AUTOSIZE);
//Loop infinitely to fetch frame from camera and display it.
for(;;)
{
//Fetch frame from camera.
cap >> CameraFrame;
//Check whether received frame has valid pointer.
if( CameraFrame.empty() )
break;
//Display the received frame
imshow("Camera Preview", CameraFrame);
//Wait for Escape keyevent to exit from loop
keypressed = (char)waitKey(10);
if( keypressed == 27 )
break;
}
//Release the camera interface.
cap.release();
↧
Explaination about LDA class / methods
Hello,
I'm about to start a project using LDA classification. I have started reading about opencv and the LDA class, but they are still some grey areas for me compare to the theory I have read here and the associated example (1) :
- I was expected that the LDA algorithm would give me **discriminant functions** for each classes I have trained. That way, I could have used them to predict the class of my testing data, but it seems that the **outputs are eigenVectors / Values**. How can I use it ?
I have seen on this thread (2) that they perform a classic L2 norm to find the closest neighbour in the lda-subspace to predict, but I can't find any theory explanation about LDA talking about this part.
- My other point is about the processing of the LDA class. The main processing start line 986, here (3), and I can't see any **covariance matrix**, which seems to be a main operation in LDA processing (sorry if I missed it, opencv annotation is totally new for me).
If anyone could enlight me about how to use this LDA :)
Thank you !
Etienne
LINKS : (sorry for removing the 'http' part, I've no right for direct links...)
(1) : people.revoledu.com/kardi/tutorial/LDA/LDA.html
(1) : people.revoledu.com/kardi/tutorial/LDA/Numerical%20Example.html
(2) : answers.opencv.org/question/64165/how-to-perform-linear-discriminant-analysis-with-opencv/
(3) : github.com/opencv/opencv/blob/master/modules/core/src/lda.cpp
↧
ERROR using opencv_contrib with Python 3.x
Whenever I try to use something from the opencv_contrib I get an error:
----------
Ex1: In the command line
python
>>> import cv2>>> help(cv2.xfeatures2d)
AttributeError: module 'cv2' has no attribute 'xfeatures2d'
----------
Ex2: Trying to run the following code (just the first few lines)
import cv2
import sys
if __name__ == '__main__' :
tracker = cv2.Tracker_create("BOOSTING")
I Get
Traceback (most recent call last):
File "tracking.py", line 6, in
tracker = cv2.Tracker_create("BOOSTING")
AttributeError: module 'cv2' has no attribute 'Tracker_create'
----------
My seetings for the cmake were:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH= /Users/MatheusTorquato/opencv/opencv_contrib/modules \
-D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin/libpython3.6.dylib \
-D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/include/python3.6m/ \
-D PYTHON3_EXECUTABLE=$VIRTUAL_ENV/bin/python \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D BUILD_EXAMPLES=ON \
-D BUILD_opencv_cvv=OFF\
-D BUILD_opencv_adas=OFF ..
Everything looks fine.
- Configuring: Ok - [File](https://www.dropbox.com/s/7plzmetg2hng70p/configuring_output.txt?dl=0)
- Making: Ok - [File](https://www.dropbox.com/s/fxpdvfvj5q181qr/making_output.txt?dl=0)
- Installing: Ok - [File](https://www.dropbox.com/s/k3slaghx4tx4f84/Installing_output.txt?dl=0)
----------
- Python Version – 3.6.0
- OpenCV Version – ‘3.2.0-dev’
- Operating System - macOS Sierra
I've installed everything using [this](http://www.pyimagesearch.com/2016/12/05/macos-install-opencv-3-and-python-3-5/#comment-420398) tutorial
Any ideas?
Regards,
Matheus Torquato
↧
↧
I have the codes for live video and finding contours separately.I would like to know how both the codes can be stitched together to find contours in a live video
CODE FOR LIVE VIDEO
#include
#include
using namespace cv;
using namespace std;
int main()
{
Mat CameraFrame;
Mat Grey;
VideoCapture cap;
char keypressed;
//Opens the first imaging device.
cap.open(0);
//Check whether user selected camera is opened successfully.
if( !cap.isOpened() )
{
cout << "***Could not initialize capturing...***\n";
return -1;
}
//Create a windows to display camera preview.
namedWindow("Camera Preview", CV_WINDOW_AUTOSIZE);
//Loop infinitely to fetch frame from camera and display it.
for(;;)
{
//Fetch frame from camera.
cap >> CameraFrame;
//Check whether received frame has valid pointer.
if( CameraFrame.empty() )
break;
//Display the received frame
imshow("Camera Preview", CameraFrame);
//Wait for Escape keyevent to exit from loop
keypressed = (char)waitKey(10);
if( keypressed == 27 )
break;
}
//Release the camera interface.
cap.release();
return 0;
}
CODE FOR FINDING CONTOURS
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include
#include
#include
using namespace cv;
using namespace std;
Mat src; Mat src_gray;
int thresh = 100;
int max_thresh = 255;
RNG rng(12345);
/// Function header
void thresh_callback(int, void* );
/** @function main */
int main( int argc, char** argv )
{
/// Load source image and convert it to gray
src = imread( argv[1], 1 );
/// Convert image to gray and blur it
cvtColor( src, src_gray, CV_BGR2GRAY );
blur( src_gray, src_gray, Size(3,3) );
/// Create Window
char* source_window = "Source";
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
imshow( source_window, src );
createTrackbar( " Threshold:", "Source", &thresh, max_thresh, thresh_callback );
thresh_callback( 0, 0 );
waitKey(0);
return(0);
}
/** @function thresh_callback */
void thresh_callback(int, void* )
{
Mat threshold_output;
vector> contours;
vector hierarchy;
/// Detect edges using Threshold
threshold( src_gray, threshold_output, thresh, 255, THRESH_BINARY );
/// Find contours
findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
/// Approximate contours to polygons + get bounding rects and circles
vector> contours_poly( contours.size() );
vector boundRect( contours.size() );
vectorcenter( contours.size() );
vectorradius( contours.size() );
for( int i = 0; i < contours.size(); i++ )
{ approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );
boundRect[i] = boundingRect( Mat(contours_poly[i]) );
minEnclosingCircle( (Mat)contours_poly[i], center[i], radius[i] );
}
/// Draw polygonal contour + bonding rects + circles
Mat drawing = Mat::zeros( threshold_output.size(), CV_8UC3 );
for( int i = 0; i< contours.size(); i++ )
{
Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
drawContours( drawing, contours_poly, i, color, 1, 8, vector(), 0, Point() );
rectangle( drawing, boundRect[i].tl(), boundRect[i].br(), color, 2, 8, 0 );
circle( drawing, center[i], (int)radius[i], color, 2, 8, 0 );
}
/// Show in a window
namedWindow( "Contours", CV_WINDOW_AUTOSIZE );
imshow( "Contours", drawing );
}
↧
Why is ShapeContextDistanceExtractor::computeDistance not commutative?
Hey,
I'm trying to use ShapeContextDistanceExtractor to find distances between contours, and for some reason changing the order of arguments in computeDistance method leads to different results. For example, here are two contours
Contour #1
0 14
2 12
4 10
6 8
8 7
10 6
13 5
15 4
18 3
20 2
22 1
24 1
27 0
29 0
31 0
33 0
36 0
38 0
41 0
43 1
45 1
47 2
49 3
51 4
55 5
57 6
59 7
61 8
63 9
65 11
68 13
66 13
64 14
62 15
60 15
58 16
55 17
53 18
50 18
48 19
46 19
44 20
41 20
39 20
37 21
35 21
32 21
30 22
27 22
25 22
23 22
21 22
19 22
16 21
13 19
11 18
9 18
7 17
5 16
3 15
Contour #2
0 15
2 13
5 10
7 9
10 7
12 6
15 4
17 3
20 2
22 1
25 1
27 0
30 0
32 0
35 0
37 0
40 0
42 1
45 2
47 2
50 4
52 5
55 6
57 7
60 10
62 11
65 13
67 15
69 18
69 20
69 23
67 24
65 25
62 26
60 27
57 29
55 29
52 30
50 31
47 32
45 33
42 33
40 34
37 34
35 34
32 34
30 34
27 34
25 34
22 33
20 32
17 31
15 31
12 29
10 28
7 26
5 24
2 22
0 20
0 17
Depending on the order of arguments computeDistance returns either 0.32094 or 0.26297. Why is this method not commutative? And does order of points inside contours affect the resulting distance?
↧
Windows Compilation mtx not std
hi, i'm trying to install the OpenCV on windows 7 but I'm reaching an error which says mutex and thread is not a member of std. I've downloaded both opencv and it's contribs and unzipped them in the root/opencv/source direction.
first i generated it with cmake afterward i tried to use the command:
`make -j5`
in order to compile it, but, I'm facing with the error of:
c:\ROOT\opencv\opencv>cd c://root/opencv/opencv && make -j5
[ 2%] Built target zlib
[ 6%] Built target libtiff
[ 10%] Built target libjpeg
[ 15%] Built target libwebp
[ 19%] Built target libjasper
[ 21%] Built target libpng
[ 27%] Built target IlmImf
[ 27%] Built target opencv_core_pch_dephelp
[ 28%] Built target pch_Generate_opencv_core
[ 33%] Built target opencv_core
[ 33%] Built target opencv_test_core_pch_dephelp
[ 33%] Built target pch_Generate_opencv_test_core
[ 33%] Built target opencv_imgproc_pch_dephelp
[ 33%] Built target pch_Generate_opencv_imgproc
[ 38%] Built target opencv_imgproc
[ 38%] Built target opencv_videoio_pch_dephelp
[ 38%] Built target pch_Generate_opencv_videoio
[ 38%] Built target opencv_imgcodecs_pch_dephelp
[ 38%] Built target pch_Generate_opencv_imgcodecs
[ 40%] Built target opencv_imgcodecs
[ 41%] Built target opencv_videoio
[ 41%] Built target opencv_highgui_pch_dephelp
[ 41%] Built target pch_Generate_opencv_highgui
[ 41%] Built target opencv_highgui
[ 41%] Built target opencv_ts_pch_dephelp
[ 41%] Built target pch_Generate_opencv_ts
[ 42%] Built target opencv_ts
[ 45%] Built target opencv_test_core
[ 45%] Built target opencv_perf_core_pch_dephelp
[ 45%] Built target pch_Generate_opencv_perf_core
[ 48%] Built target opencv_perf_core
[ 48%] Built target opencv_flann_pch_dephelp
[ 48%] Built target pch_Generate_opencv_flann
[ 49%] Built target opencv_flann
[ 49%] Built target opencv_test_flann_pch_dephelp
[ 49%] Built target pch_Generate_opencv_test_flann
[ 50%] Built target opencv_test_flann
[ 50%] Built target opencv_perf_imgproc_pch_dephelp
[ 50%] Built target opencv_test_imgproc_pch_dephelp
[ 50%] Built target pch_Generate_opencv_test_imgproc
[ 54%] Built target opencv_test_imgproc
[ 54%] Built target pch_Generate_opencv_perf_imgproc
[ 58%] Built target opencv_perf_imgproc
[ 58%] Built target opencv_test_ml_pch_dephelp
[ 58%] Built target pch_Generate_opencv_test_ml
[ 58%] Built target opencv_ml_pch_dephelp
[ 59%] Built target pch_Generate_opencv_ml
[ 61%] Built target opencv_ml
[ 62%] Built target opencv_test_ml
[ 63%] Built target opencv_photo_pch_dephelp
[ 63%] Built target pch_Generate_opencv_photo
[ 64%] Built target opencv_photo
[ 64%] Built target opencv_perf_photo_pch_dephelp
[ 64%] Built target pch_Generate_opencv_perf_photo
[ 65%] Built target opencv_perf_photo
[ 65%] Built target opencv_test_photo_pch_dephelp
[ 65%] Built target pch_Generate_opencv_test_photo
[ 66%] Built target opencv_test_photo
[ 66%] Built target opencv_video_pch_dephelp
[ 67%] Built target pch_Generate_opencv_video
[ 69%] Built target opencv_video
[ 69%] Built target opencv_test_video_pch_dephelp
[ 69%] Built target pch_Generate_opencv_test_video
[ 70%] Built target opencv_test_video
[ 70%] Built target opencv_perf_video_pch_dephelp
[ 71%] Built target pch_Generate_opencv_perf_video
[ 72%] Built target opencv_perf_video
[ 72%] Built target opencv_test_imgcodecs_pch_dephelp
[ 72%] Built target opencv_perf_imgcodecs_pch_dephelp
[ 73%] Built target pch_Generate_opencv_test_imgcodecs
[ 74%] Built target opencv_test_imgcodecs
[ 75%] Built target pch_Generate_opencv_perf_imgcodecs
[ 75%] Built target opencv_perf_imgcodecs
[ 75%] Built target opencv_shape_pch_dephelp
[ 75%] Built target pch_Generate_opencv_shape
[ 75%] Built target opencv_shape
[ 76%] Built target opencv_test_shape_pch_dephelp
[ 77%] Built target pch_Generate_opencv_test_shape
[ 77%] Built target opencv_test_shape
[ 77%] Built target opencv_test_videoio_pch_dephelp
[ 77%] Built target pch_Generate_opencv_test_videoio
[ 78%] Built target opencv_test_videoio
[ 78%] Built target opencv_perf_videoio_pch_dephelp
[ 78%] Built target pch_Generate_opencv_perf_videoio
[ 79%] Built target opencv_perf_videoio
[ 79%] Built target opencv_test_highgui_pch_dephelp
[ 79%] Built target pch_Generate_opencv_test_highgui
[ 79%] Built target opencv_test_highgui
[ 79%] Built target opencv_perf_objdetect_pch_dephelp
[ 79%] Built target opencv_objdetect_pch_dephelp
[ 79%] Built target pch_Generate_opencv_objdetect
[ 79%] Building CXX object modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:175:14: error: 'thread' in namespace 'std' does not name a type
std::thread second_workthread;
^~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:176:14: error: 'mutex' in namespace 'std' does not name a type
std::mutex mtx;
^~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:177:14: error: 'condition_variable' in namespace 'std' does not name a type
std::condition_variable objectDetectorRun;
^~~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:178:14: error: 'condition_variable' in namespace 'std' does not name a type
std::condition_variable objectDetectorThreadStartStop;
^~~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::setParameters(const c
v::DetectionBasedTracker::Parameters&)':
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:143:30: error: 'mutex' is not a member of 'std'
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:143:30: error: 'mutex' is not a member of 'std'
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:143:40: error: template argument 1 is invalid
std::unique_lock mtx_lock(mtx);
^
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:143:51: error: 'mtx' was not declared in this scope
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:143:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
std::unique_lock mtx_lock(mtx);
^~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::init()':
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:156:30: error: 'mutex' is not a member of 'std'
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:156:30: error: 'mutex' is not a member of 'std'
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:156:40: error: template argument 1 is invalid
std::unique_lock mtx_lock(mtx);
^
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:156:51: error: 'mtx' was not declared in this scope
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:164:13: error: 'objectDetectorThreadStartStop' was not declared in this scope
objectDetectorThreadStartStop.notify_one();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:156:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
std::unique_lock mtx_lock(mtx);
^~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp: In destructor 'virtual cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork(
)':
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:253:5: error: 'second_workthread' was not declared in this scope
second_workthread.join();
^~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::run()':
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:260:22: error: 'mutex' is not a member of 'std'
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:260:22: error: 'mutex' is not a member of 'std'
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:260:32: error: template argument 1 is invalid
std::unique_lock mtx_lock(mtx);
^
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:260:43: error: 'mtx' was not declared in this scope
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:274:5: error: 'second_workthread' was not declared in this scope
second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
^~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:274:25: error: 'thread' is not a member of 'std'
second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:275:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
objectDetectorThreadStartStop.wait(mtx_lock);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetect
or()':
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:316:22: error: 'mutex' is not a member of 'std'
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:316:22: error: 'mutex' is not a member of 'std'
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:316:32: error: template argument 1 is invalid
std::unique_lock mtx_lock(mtx);
^
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:316:43: error: 'mtx' was not declared in this scope
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:322:9: error: 'objectDetectorThreadStartStop' was not declared in this scope
objectDetectorThreadStartStop.notify_one();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:329:9: error: 'objectDetectorRun' was not declared in this scope
objectDetectorRun.wait(mtx_lock);
^~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:339:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
mtx_lock.unlock();
^~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:356:22: error: request for member 'lock' in 'mtx_lock', which is of non-class type 'int'
mtx_lock.lock();
^~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:363:26: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
mtx_lock.unlock();
^~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:371:13: error: 'objectDetectorRun' was not declared in this scope
objectDetectorRun.wait(mtx_lock);
^~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:379:22: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
mtx_lock.unlock();
^~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:430:18: error: request for member 'lock' in 'mtx_lock', which is of non-class type 'int'
mtx_lock.lock();
^~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:446:18: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
mtx_lock.unlock();
^~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::stop()':
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:461:20: error: 'mutex' is not a member of 'std'
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:461:20: error: 'mutex' is not a member of 'std'
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:461:30: error: template argument 1 is invalid
std::unique_lock mtx_lock(mtx);
^
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:461:41: error: 'mtx' was not declared in this scope
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:467:18: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
mtx_lock.unlock();
^~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:478:5: error: 'objectDetectorRun' was not declared in this scope
objectDetectorRun.notify_one();
^~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:479:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
objectDetectorThreadStartStop.wait(mtx_lock);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:481:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
mtx_lock.unlock();
^~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking()':
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:494:22: error: 'mutex' is not a member of 'std'
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:494:22: error: 'mutex' is not a member of 'std'
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:494:32: error: template argument 1 is invalid
std::unique_lock mtx_lock(mtx);
^
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:494:43: error: 'mtx' was not declared in this scope
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:511:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
mtx_lock.unlock();
^~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetect
ingThread(const cv::Mat&, std::vector>&)':
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:532:22: error: 'mutex' is not a member of 'std'
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:532:22: error: 'mutex' is not a member of 'std'
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:532:32: error: template argument 1 is invalid
std::unique_lock mtx_lock(mtx);
^
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:532:43: error: 'mtx' was not declared in this scope
std::unique_lock mtx_lock(mtx);
^~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:565:9: error: 'objectDetectorRun' was not declared in this scope
objectDetectorRun.notify_one();
^~~~~~~~~~~~~~~~~
C:\ROOT\opencv\sources\modules\objdetect\src\detection_based_tracker.cpp:572:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
mtx_lock.unlock();
^~~~~~
make[2]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj] Error 1
make[1]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/all] Error 2
make: *** [all] Error 2
in the process of compilation. What can i do to fix this error?
Thanks in Advance,
Regards
↧
Linking error when building OpenCV 3.2.0 with Python support
I build OpenCV 3.2.0 from the sources (including the contrib modules) using the `3.2.0` branch. And when I import it within python, through `import cv2`, I get an `undefined symbol` error. That in my experience seems like a linking error.
$ python
Python 2.7.12+ (default, Sep 17 2016, 12:08:02)
[GCC 6.2.0 20160914] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "", line 1, in
ImportError: /usr/local/lib/python2.7/dist-packages/cv2.so: undefined symbol: _Z13pyopencv_fromIN2cv4MatxIdLi4ELi4EEEEP7_objectRKT_>>>
$ python3
Python 3.5.2+ (default, Sep 22 2016, 12:18:14)
[GCC 6.2.0 20160927] on linux
Type "help", "copyright", "credits" or "license" for more information.>>> import cv2
Traceback (most recent call last):
File "", line 1, in
ImportError: /usr/local/lib/python3.5/dist-packages/cv2.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _Z13pyopencv_fromIN2cv4MatxIdLi4ELi4EEEEP7_objectRKT_>>>
My `gcc`
$ gcc --version
gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
My flags in `cmake` are as follows:
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D WITH_TBB=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D BUILD_TIFF=ON \
-D BUILD_SHARED_LIBS=OFF \
-D BUILD_EXAMPLES=ON \
..
I see in other posts that the problem my be due to the sharing libraries, and so I tried with `-D BUILD_SHARED_LIBS=OFF` but that doesn't work either. My system is
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.10
Release: 16.10
Codename: yakkety
Let me know if you need more information. Any help is appreciated.
↧
↧
how to run the live stream from the wifi camera which is inbuilt wifi.I want to connect it with my laptop for face recognition. The face recognition coding is ready working in python-opencv. cam=Videocapture(0) is the syntax used for running lap camera?
sony sj cam
↧
What is the license of OpenCV documentations?
I want to add this documentation to devdocs.io, but the documentation's license must permit alteration, redistribution and commercial use.
↧
Opencl computation time increases after few iterations
I am using opencl module provided by opencv on Qualcomm Snapdragon 805 Inforce 6501.The problem is that the time taken for the execution of opencv's remap function with oclMat after about 20 iterations is around 700 microseconds but if I call it for 50 iteration or more execution time rises to 50ms after about 30 iterations.
The code i am using is as follows
Mat xMap1,yMap1,mDst;
Mat xMap2,yMap2;
Mat xMap3,yMap3;
bool first = true;
oclMat osXMap,osYMap;
oclMat conSrc;
oclMat conDst;
oclMat oclXMap,oclYMap;
oclMat oclSrc;
oclMat oclDst1;
oclMat oclDst2;
Mat imageSrc = cv::imread("/storage/sdcard0/DCIM/Camera/2048.jpg");
FileStorage fsx("/storage/sdcard0/DCIM/Camera/FishEyeConversionXmap4.yml",FileStorage::READ);
FileStorage fsy("/storage/sdcard0/DCIM/Camera/FishEyeConversionYmap4.yml",FileStorage::READ);
fsx["xMap"] >> xMap1;
fsy["yMap"] >> yMap1;
fsx.release();
fsy.release();
oclSrc = imageSrc;
oclDst1 = oclSrc.clone();
oclDst2 = oclSrc.clone();
oclXMap= xMap1;
oclYMap= yMap1;
cout<<"Remaping\n";
for(int i=0; i<50; i++)
//while(1)
{
unsigned long long t1 = GetTime();
remap(oclSrc,oclDst1,oclXMap,oclYMap,CV_INTER_LINEAR,BORDER_CONSTANT);
remap(oclSrc,oclDst2,oclXMap,oclYMap,CV_INTER_LINEAR,BORDER_CONSTANT);
unsigned long long t2 = GetTime();
printf("%d Time taken remap : %llu microseconds for %f ms\n",i, t2-t1,(float)((t2-t1)/(1000)));
}
And this is the output I get.
0 Time taken remap : 11946 microseconds for 11.000000 ms
1 Time taken remap : 817 microseconds for 0.000000 ms
2 Time taken remap : 800 microseconds for 0.000000 ms
3 Time taken remap : 258 microseconds for 0.000000 ms
4 Time taken remap : 754 microseconds for 0.000000 ms
5 Time taken remap : 885 microseconds for 0.000000 ms
6 Time taken remap : 764 microseconds for 0.000000 ms
7 Time taken remap : 966 microseconds for 0.000000 ms
8 Time taken remap : 783 microseconds for 0.000000 ms
9 Time taken remap : 757 microseconds for 0.000000 ms
10 Time taken remap : 1050 microseconds for 1.000000 ms
11 Time taken remap : 445 microseconds for 0.000000 ms
12 Time taken remap : 798 microseconds for 0.000000 ms
13 Time taken remap : 758 microseconds for 0.000000 ms
14 Time taken remap : 765 microseconds for 0.000000 ms
15 Time taken remap : 978 microseconds for 0.000000 ms
16 Time taken remap : 1120 microseconds for 1.000000 ms
17 Time taken remap : 763 microseconds for 0.000000 ms
18 Time taken remap : 766 microseconds for 0.000000 ms
19 Time taken remap : 607 microseconds for 0.000000 ms
20 Time taken remap : 258 microseconds for 0.000000 ms
21 Time taken remap : 305 microseconds for 0.000000 ms
22 Time taken remap : 767 microseconds for 0.000000 ms
23 Time taken remap : 750 microseconds for 0.000000 ms
24 Time taken remap : 783 microseconds for 0.000000 ms
25 Time taken remap : 769 microseconds for 0.000000 ms
26 Time taken remap : 782 microseconds for 0.000000 ms
27 Time taken remap : 4588 microseconds for 4.000000 ms
28 Time taken remap : 301 microseconds for 0.000000 ms
29 Time taken remap : 284 microseconds for 0.000000 ms
30 Time taken remap : 26658 microseconds for 26.000000 ms
31 Time taken remap : 498 microseconds for 0.000000 ms
32 Time taken remap : 26263 microseconds for 26.000000 ms
33 Time taken remap : 493 microseconds for 0.000000 ms
34 Time taken remap : 55254 microseconds for 55.000000 ms
35 Time taken remap : 50391 microseconds for 50.000000 ms
36 Time taken remap : 53969 microseconds for 53.000000 ms
37 Time taken remap : 110516 microseconds for 110.000000 ms
38 Time taken remap : 52030 microseconds for 52.000000 ms
39 Time taken remap : 54376 microseconds for 54.000000 ms
40 Time taken remap : 54264 microseconds for 54.000000 ms
41 Time taken remap : 54148 microseconds for 54.000000 ms
42 Time taken remap : 53658 microseconds for 53.000000 ms
43 Time taken remap : 54422 microseconds for 54.000000 ms
44 Time taken remap : 3529 microseconds for 3.000000 ms
↧
How to define the “lower” and “upper” range of a color?
Hi, could you please help me with a question defining the range of a certain color?
Learning from the question and answers in the site /31305/why-is-this-simple-mask-not-working/
The lines limiting the red are 2 arrays:
lower = n.array([0,100,100])
upper = n.array([20,255,255])
how are these arrays are formed?
The RGB of red is (255, 0, 0) and its HSV is (0°, 100°, 100°)
How’s the RGB 255,0,0 to be relevant into ([0,100,100]) and ([20,255,255])? (reading it BGR shall be 0,0,255)
Thank you.
↧
↧
MatOfPoint image transportation
Hi,
I'm developing a document scanner using OpenCV and I succesfully detected and drawed the contour on the preview of the JavaCameraView, now I want to take a picture and use the detected points to extract that part of the image from the newly taken image. That image taken by the camera is bigger than the preview, is there a way to use the same MatOfPoint in the new image "transporting" (I don't know if it's the right word) the points?
Thanks
↧
upload GpuMat from memory pointer
I want to upload a camera image to a GpuMat without unnecessary copy operations.
I get the image as a naked char* from the camera API and at the moment convert it to a GpuMat approximately like this:
is_GetImageMem(hCam, (void*)pLast);
tmpI = cvCreateImageHeader(cvSize(iWidth, iHeight), IPL_DEPTH_8U, 1);
tmpI->imageData = pLast;
Mat M = cv::cvarrToMat(tmpI);
GpuMat gM.upload(M);
Is this the "optimal" way to do it without copying data around? The CPU memory gets overwritten by the camera next time around, is this OK after I uploaded it to the GPU?
Thanks!
↧
Building OpenCV 2.4 for arm64-v8a or x86_64 (CMake / make)
I tried to compile OpenCV 2.4.11 for arm64-v8a, but there is only one `.so` file I got after building in `my_build\lib\arm64-v8a` folder: `libopencv_info.so` (others are `.a`)
What did I do wrong?
It should also have built `libopencv_java.so` & `libnative_camera_r*.so` files, but it haven't
cmake parameters:
cd opencv\platforms
mkdir build_android_arm
cd build_android_arm
cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=..\android\android.toolchain.cmake -DANDROID_ABI="arm64-v8a" -DWITH_TBB=ON -DINSTALL_ANDROID_EXAMPLES=ON -DANDROID_NATIVE_API_LEVEL=16 -D WITH_OPENCL=OFF -D WITH_OPENCL_SVM=OFF -D WITH_OPENCLAMDFFT=OFF -D WITH_OPENCLAMDBLAS=OFF ..\..
make
OpenCV 2.4.11 source code: github.com/opencv/opencv/releases/tag/2.4.11
↧
picamera alternative in openCV(C++)
Hi,
There is a python package available for controlling Raspberry Pi camera called [picamera](https://picamera.readthedocs.io/en/release-1.13/#) which exposes all the options available in [raspistill](https://www.raspberrypi.org/documentation/raspbian/applications/camera.md).
I need to access/change the "sensor mode" (which changes the resolution) for capturing. I am using openCV (C++) for my application but there is no option to change "sensor mode" available in `cv::VideoCapture::set`. There is a field of `CV_CAP_PROP_MODE` but that is not the same. So my question is:
1. Is there a way to change the "sensor
mode" in openCV?
2. If not, then is there a C++
alternative available like
[picamera](https://picamera.readthedocs.io/en/release-1.13/#)?
3. If not, then is there a way to use this python package in my C++ program?
↧
↧
Camera selection for running ArUco
I want to implement pose estimation using ArUco markers. For this, I want to know what should be the ideal specs for the camera to choose for running ArUco. I have an outdoor area of 100x300 meters in which I want to run ArUco marker detection. Any suggestions for which camera should I choose that works best for this applicatoin? Thanks
↧
OpenCV: append different vectors as one row
I have a `cv::Mat1f` vector which size is `kxd`. How can I fill it by appending `k` different `1xd` vectors?
I want to do something like:
int k = 3, d = 3;
cv::Mat1f testMat(1,k*d);
for(int i=0; i
↧
Initialize MAT from pointer - help.
Hi,
Im working with a camera, and the camera gives me the image in its own type of variable, that contains image width , height , depth , and other things.
In this data i receive a pointer for the first pixel , and i know that the RGB is organized like (assuming the image as n pixels), the first n address have the R, the next n address have the G and the last n address have the B.
So im trying to initialize the image like this.
cv::Mat dummy_query = cv::Mat(img->h, img->w, CV_8UC3, pData , 0 );
pData is the pointer from the first pixel.
the 0 ,on openCV doc they say its the step , i really dont understand what is this step.
whit this i get some data to the matrix, but when i do the imshow nothing happens.
hope someone can help. =)
↧