Ask Your Question

AlexMagsam's profile - activity

2017-07-11 11:45:30 -0500 asked a question Seg Fault using .at()

I just upgraded to OpenCV 3.2 and am receiving Seg Fault errors when accessing elements in an image.

cv::Mat image =cv::imread("imZstack_1.tiff",CV_LOAD_IMAGE_GRAYSCALE);
image.convertTo(image,CV_32FC1);
std::cout<<image.at<float>(1,1);

Compiled with: g++ C2C_fft.cpp -I /usr/include -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -L/usr/local/cuda-8.0/lib64 -lcufft -lcudart -lcufftw -o fft

2017-07-10 13:58:11 -0500 commented answer GPU Face Detection Error

OpenCV Error: Gpu API call (NCV Assertion Failed: cudaError_t=18, file=/hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/nvidia/NPP_staging/NPP_staging.cu, line=337 ) in NCVDebugOutputHandler, file /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/cascadeclassifier.cpp, line 173 terminate called after throwing an instance of 'cv::Exception' what(): /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/cascadeclassifier.cpp:173: error: (-217) NCV Assertion Failed: cudaError_t=18, file=/hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/nvidia/NPP_staging/NPP_staging.cu, line=337 in function NCVDebugOutputHandler

2017-07-10 13:57:12 -0500 commented answer GPU Face Detection Error

What next, copy the source code to a new xml file? I tried this and did not work.

2017-07-10 13:28:32 -0500 commented answer GPU Face Detection Error

Thank you for the response, this makes sense. I currently have OpenCV 2.4 running on my TX2, do I have to upgrade to OpenCV 3.0 or higher to have access to this other xml file? I was not able to download it from the link you sent.

2017-07-10 12:46:37 -0500 asked a question GPU Face Detection Error

I need help with an error in my simple GPU face detection program. The CPU version of this code runs fine with the same CascadeClassifier. This program is running on a NVIDIA TX2.

Error: OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/core/src/persistence.cpp, line 5008 terminate called after throwing an instance of 'cv::Exception' what(): /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/core/src/persistence.cpp:5008: error: (-2) The node does not represent a user object (unknown type?) in function cvRead

Code :

#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include<opencv2/highgui/highgui.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <opencv2/gpu/gpumat.hpp>
#include <stdlib.h>
#include <chrono>
#include <iostream> 

int main()
{

using std::chrono::duration_cast;
    using std::chrono::nanoseconds;
    typedef std::chrono::high_resolution_clock clock;


cv::Mat img = cv::imread("lena.tiff",CV_LOAD_IMAGE_GRAYSCALE);
cv::equalizeHist(img,img);
auto start = clock::now();

cv::gpu::GpuMat image_gpu(img);


cv::gpu::CascadeClassifier_GPU face_detector_gpu("/usr/share/OpenCV/haarcascades/haarcascade_frontalface_default.xml");


cv::gpu::GpuMat objbuf;
int detections = face_detector_gpu.detectMultiScale(image_gpu, objbuf);

cv::Mat obj_host;
objbuf.colRange(0,detections).download(obj_host);

cv::Rect* gpu_faces = obj_host.ptr<cv::Rect>();
for (int i=0;i<detections;i++)
    cv::rectangle(img,gpu_faces[i],cv::Scalar(255));


auto end = clock::now();
    std::cout << duration_cast<nanoseconds>(end-start).count()/1000000 << "ms\n";


cv::imshow("img",img);
cv::waitKey();

return 0;

}

Compiled with: g++ -std=c++11 main.cpp -I/usr/include -lopencv_core -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_objdetect -o main