Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all 41027 articles
Browse latest View live

Parallel READ Access on Mats

$
0
0
Hello all, i want to speedup an algorithm (complete local binary pattern with circle neighbours) for which i iterate trough all pixels and calculate some stuff with it neighbours (so i need neighbour pixel access). Currently i do this by iterating over all pixels with one thread/process. I want to parallelize this task by dividing the input image into multiple ROIs and calculate each ROI seperatly (with multiple threads). The Problem here is, that the ROIs are overlapping (because to calculate a pixel, sometimes i need to look at neighbours far away) and its possible that multiple threads accessing Pixel-Data (**READING**) at same time. Is that a Problem if two or more threads reading same Mat at same Indices at same time? Is it also a problem, if i write to the same Mat parallel but at different indices?

cv2.undistortPoints: -215:Assertion failed; src seems to have an invalid format

$
0
0
I am running the following code in python. I am only including the src since that is the source of the assertion error. I am not sure what is happening in this instance, and would appreciate the assistance. Thanks in advance points_cam1 = np.array([[[1232., 1004.]]]) cv2.undistortPoints(src=points_cam1, cameraMatrix=mtx_l, distCoeffs=dist_l, P=P1, R=R1) error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\calib3d\src\undistort.cpp:569: error: (-215:Assertion failed) src.isContinuous() && (src.depth() == CV_32F || src.depth() == CV_64F) && ((src.rows == 1 && src.channels() == 2) || src.cols*src.channels() == 2) in function 'cv::undistortPoints'

OpenCV on Android: net.forward yields "blobs.size() >= 2" Assertion failed

$
0
0
Following [this tutorial from openCV](https://docs.opencv.org/master/d0/d6c/tutorial_dnn_android.html), and it should be straight forward. However, it crashes with an assertion fail on the net.forward, that I cannot resolve/find anywhere else. Thought [this problem](https://github.com/opencv/opencv/issues/9904) seemed similar and tried to go through the fix/problem finding. However, restarting the discussion and trials showed it is likely not the same. I used initially 3.4.3, which did not support the same Mat type somehow. Updated to 3.4.7 now, and can confirm the blob size is okay (generated from image). Tried also various other prototxt and caffemodels, but doubt by now that the problem lies there (works if the files are okay, otherwise the net loading fails). The key code should be this: // Load a network. public void onCameraViewStarted(int width, int height) { String proto = getPath("deploy.prototxt", this); String weights = getPath("MobileNetSSD_deploy.caffemodel", this); net = Dnn.readNetFromCaffe(proto, weights); Log.i(TAG, "Network loaded successfully"); } public Mat onCameraFrame(CvCameraViewFrame inputFrame) { // Get a new frame Mat frame = inputFrame.rgba(); Imgproc.cvtColor(frame, frame, Imgproc.COLOR_RGBA2RGB); // Forward image through network. Mat blob = Dnn.blobFromImage(frame, 0.007843, new Size(300, 300), new Scalar(127.5, 127.5, 127.5)); net.setInput(blob); Mat detections = net.forward(); //***215 ASSERTION FAILED occurs*** int cols = frame.cols(); int rows = frame.rows(); detections = detections.reshape(1, (int)detections.total() / 7); for (int i = 0; i < detections.rows(); ++i) { double confidence = detections.get(i, 2)[0]; if (confidence > 0.2) { int classId = (int)detections.get(i, 1)[0]; int left = (int)(detections.get(i, 3)[0] * cols); int top = (int)(detections.get(i, 4)[0] * rows); int right = (int)(detections.get(i, 5)[0] * cols); int bottom = (int)(detections.get(i, 6)[0] * rows); // Draw rectangle around detected object. Imgproc.rectangle(frame, new Point(left, top), new Point(right, bottom), new Scalar(0, 255, 0)); String label = classNames[classId] + ": " + confidence; int[] baseLine = new int[1]; Size labelSize = Imgproc.getTextSize(label, Core.FONT_HERSHEY_SIMPLEX, 0.5, 1, baseLine); // Draw background for label. Imgproc.rectangle(frame, new Point(left, top - labelSize.height), new Point(left + labelSize.width, top + baseLine[0]), new Scalar(255, 255, 255), Core.FILLED); // Write class name and confidence. Imgproc.putText(frame, label, new Point(left, top), Core.FONT_HERSHEY_SIMPLEX, 0.5, new Scalar(0, 0, 0)); } } return frame; } public void onCameraViewStopped() {} // Upload file to storage and return a path. private static String getPath(String file, Context context) { AssetManager assetManager = context.getAssets(); BufferedInputStream inputStream = null; try { // Read data from assets. inputStream = new BufferedInputStream(assetManager.open(file)); byte[] data = new byte[inputStream.available()]; inputStream.read(data); inputStream.close(); // Create copy file in storage. File outFile = new File(context.getFilesDir(), file); FileOutputStream os = new FileOutputStream(outFile); os.write(data); os.close(); // Return a path to file which may be read in common way. return outFile.getAbsolutePath(); } catch (IOException ex) { Log.i(TAG, "Failed to upload a file"); } return ""; } The full error message is > cv::Exception: OpenCV(3.4.7) /build/3_4_pack-android/opencv/modules/dnn/src/layers/batch_norm_layer.cpp:39: error: (-215:Assertion failed) blobs.size() >= 2 in function 'cv::dnn::BatchNormLayerImpl::BatchNormLayerImpl(const cv::dnn::experimental_dnn_34_v13::LayerParams&)' I expect it to not crash. The frame should be okay (image loaded), the net is not empty, and the layers in the net seem fine too (checked since there are some differences using caffe in java). Any help is appreciated!

Error: no member named 'FlannBasedMatcher' in namespace 'cv'

$
0
0
Error infomation is shown following: [ 96%] Linking CXX executable ../../bin/opencv_interactive-calibration [ 97%] Building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o [ 98%] Built target opencv_version [ 98%] Built target opencv_annotation [ 98%] Built target opencv_visualisation In file included from /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/modules/python/src2/cv2.cpp:1498: /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:1148:50: error: no member named 'FlannBasedMatcher' in namespace 'cv' template<> PyObject* pyopencv_from(const Ptr& r) ~~~~^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:1156:52: error: no member named 'FlannBasedMatcher' in namespace 'cv' template<> bool pyopencv_to(PyObject* src, Ptr& dst, const char* name) ~~~~^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:1165:67: error: no member named 'FlannBasedMatcher' in namespace 'cv' dst = ((pyopencv_FlannBasedMatcher_t*)src)->v.dynamicCast(); ~~~~^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:1165:85: error: expected unqualified-id dst = ((pyopencv_FlannBasedMatcher_t*)src)->v.dynamicCast(); ^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:13528:9: error: use of undeclared identifier 'flann' Ptr indexParams=makePtr(); ^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:13530:9: error: use of undeclared identifier 'flann' Ptr searchParams=makePtr(); ^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:13534:40: error: use of undeclared identifier 'indexParams' pyopencv_to(pyobj_indexParams, indexParams, ArgInfo("indexParams", 0)) && ^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:13535:41: error: use of undeclared identifier 'searchParams' pyopencv_to(pyobj_searchParams, searchParams, ArgInfo("searchParams", 0)) ) ^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:13537:34: error: no member named 'FlannBasedMatcher' in namespace 'cv' new (&(self->v)) Ptr(); // init Ptr with placement new ~~~~^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:13538:49: error: no type named 'FlannBasedMatcher' in namespace 'cv' if(self) ERRWRAP2(self->v.reset(new cv::FlannBasedMatcher(indexParams, searchParams))); ~~~~^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/modules/python/src2/cv2.cpp:77:5: note: expanded from macro 'ERRWRAP2' expr; \ ^~~~ In file included from /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/modules/python/src2/cv2.cpp:1498: /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:13549:9: error: use of undeclared identifier 'FlannBasedMatcher' Ptr retval; ^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:13553:18: error: use of undeclared identifier 'retval' ERRWRAP2(retval = cv::FlannBasedMatcher::create()); ^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:13553:31: error: no member named 'FlannBasedMatcher' in namespace 'cv' ERRWRAP2(retval = cv::FlannBasedMatcher::create()); ~~~~^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/modules/python/src2/cv2.cpp:77:5: note: expanded from macro 'ERRWRAP2' expr; \ ^~~~ In file included from /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/modules/python/src2/cv2.cpp:1498: /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_types.h:13554:30: error: use of undeclared identifier 'retval' return pyopencv_from(retval); ^ In file included from /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/modules/python/src2/cv2.cpp:1499: /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_funcs.h:443:9: error: use of undeclared identifier 'FlannBasedMatcher' Ptr retval; ^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_funcs.h:447:18: error: use of undeclared identifier 'retval' ERRWRAP2(retval = cv::FlannBasedMatcher::create()); ^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_funcs.h:447:31: error: no member named 'FlannBasedMatcher' in namespace 'cv' ERRWRAP2(retval = cv::FlannBasedMatcher::create()); ~~~~^ /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/modules/python/src2/cv2.cpp:77:5: note: expanded from macro 'ERRWRAP2' expr; \ ^~~~ In file included from /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/modules/python/src2/cv2.cpp:1499: /Users/zhuangjiankai/Desktop/libycnn2_linux/3rdparty/opencv331/build_opencv_static/modules/python2/pyopencv_generated_funcs.h:448:30: error: use of undeclared identifier 'retval' return pyopencv_from(retval); ^ [100%] Built target opencv_interactive-calibration 18 errors generated. make[2]: *** [modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o] Error 1 make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2 make: *** [all] Error 2 ~/Desktop/libycnn2_linux

Hire someone for build environment setup for Android

$
0
0
Does anyone know of someone I could hire to setup a build environment for opencv from source? I've been at it for a while and I just can't seem to get the final building of the android project piece to work. Thank you

Non-free algorithms stays NO Ubuntu 16.04 opencv-3.4.4

$
0
0
Hi, I am on Ubuntu 16.04 (clean install) following this [tutorial](https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/) . Instead of 3.1.0 I tried to install 3.4.6 which did not work, because the Non-free algorithms are not being included. I again tried with version 3.4.4 which again did not work. Here is a screenshot of the CMAKE output: ![image](https://i.imgur.com/8Q5rJ3d.png?1) The CMAKE command I use: cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D INSTALL_C_EXAMPLES=OFF \ -D OPENCV_ENABLE_NONFREE=ON \ -D OPENCV_EXTRA_MODULES_PATH=/home/gertjan/opencv_contrib-3.4.4/modules \ -D BUILD_EXAMPLES=ON .. I need the non-free algortihms for the use of SIFT.

How to implement indoor SLAM in mobile robot with stereo vision?

$
0
0
Hi there! I am currently developing a autonomous humanoid home assistant robot. This robot have two cameras and stereo vision. I want to make this robot navigate in home. I spend lot time googling about SLAM and as far as I understand for it consists of three main steps 1. Localize robot using odometry 2. Build map using depth images 3. Navigate in this map, build routes and so on I found some info about localization and odometry([here](https://avisingh599.github.io/vision/visual-odometry-full/) and [here](https://avisingh599.github.io/vision/monocular-vo/)) and i found suitable [implementation](https://github.com/prostoiChelovek/visual_odom) that works good with KITTI dataset, but when i tried to use it with my cameras and calibration parameters it do not works but only shows one point. I was able to reproduce this by skipping every second frame from dataset. But this topic is most clear for me and i believe that i can solve this problems. The third step is also relatively clear for me - i found a lot of articles about navigation algorithms such as A* and i think that i can implement this. But i could not find any understandable information about map building using stereo map(not lidars or something like it). As far i understand for do it i must store depth data in some format relative robots position estimated by odometry, and it will be a 2D view from above. But my best approach was to iterate over depth image\`s rows and get the most common depth value from column. It looks as follows ![image description](/upfiles/15653616414294288.png) This map is very unstable and i think that i doing something wrong and missed something important. So i have several questions: - Where i can find some easy to understand articles or maybe tutorials about visual odometry, map building and indoor robot navigation in general? - Is there ready for use implementation of odometry and map building made for indoor robots? - How to build map using a stereo vision? - Why [that](https://github.com/prostoiChelovek/visual_odom) implementation not works with robots (as i think it is because of slow speed) and how to solve this? I am sorry for lot of questions but now i confused and cannot find any more information that i can understand and so i want some explanation from more experienced people. Thanks!

OpenCV face detection results in "debug assertion failed"

$
0
0
I am trying to use OpenCV 4.1.1 on Visual Studio 2013 to perform facial detection. The program works fine for 2 frames and then I get this error: Debug Assertion Failed! Program: filepath\program.exe File: f:\dd\vctools\crt\crtw32\misc\dbgheap.c Line:1424 This is my code: #include "opencv2/objdetect.hpp" #include "opencv2/highgui.hpp" #include "opencv2/imgproc.hpp" #include using namespace std; using namespace cv; void detectAndDisplay(Mat frame); CascadeClassifier face_cascade; CascadeClassifier eyes_cascade; int main(int argc, const char** argv) { face_cascade.load(filepath); eyes_cascade.load(filepath); VideoCapture cap(0); if (!cap.isOpened()) return -1; Mat frame; while (cap.read(frame)) { if (frame.empty()) { cout << "--(!) No captured frame -- Break!\n"; break; } detectAndDisplay(frame); if (waitKey(10) == 27) { break; // escape } } return 0; } void detectAndDisplay(Mat frame) { Mat frame_gray; cvtColor(frame, frame_gray, COLOR_BGR2GRAY); equalizeHist(frame_gray, frame_gray); vector faces; face_cascade.detectMultiScale(frame_gray, faces); for (size_t i = 0; i < faces.size(); i++) { Point center(faces[i].x + faces[i].width / 2, faces[i].y + faces[i].height / 2); ellipse(frame, center, Size(faces[i].width / 2, faces[i].height / 2), 0, 0, 360, Scalar(255, 0, 255), 4); } imshow("Capture - Face detection", frame); } The program works as expected for 2 frames only. It is past two frames that aforementioned error occurs. I have confirmed this by adding a counter to the following code: int i=0; while (cap.read(frame)) { if (i < 2){ detectAndDisplay(frame); } i++; I think it might have something to do with how memory is allocated within the detectAndDisplay(Mat frame) function, particularly with the frame and vector, however my understanding is that OpenCV should automatically free the previous frame to make space for the new one. I also know the cascade classifiers load correctly.

Generate full 3D image based on ChArUco calibration

$
0
0
I'm extracting the calibration parameters of two images that were taken in a stereo vision setup via `cv2.aruco.calibrateCameraCharucoExtended()`. I'm currently using the `cv2.undistortPoints()` & `cv2.triangulatePoints()` function to convert two 2D points to a 3D point, which works perfectly fine. I'm however now looking for a way to convert the two 2D images to one 3D image. I was thinking about using a keypoint feature extractor like SIFT or SURF, but how can I convert the complete image with only a few keypoints? Do I need a disparity map maybe? What functions of OpenCV can I use for this? Thanks a lot in advance!

OpenCV 4.1 + Python 3 + CUDA

$
0
0
I am going to rewrite feature matching + homography code using CUDA. I know that CUDA is implemented in OpenCV 4.1 and I have already used some of the functions of CUDA, but I'm a beginner, and the documentation is either missing or very poor, so I can not fully figure out and write code similar to the code using the CPU. Please help me deal with this issue. Or am I better off writing code using C++? I want to use Python because it is easier to write a microservice on it.

OpenCV mat.get(y,x)[0] == mat2.get(y,x)[0] returns true when false

$
0
0
Hello, I am comparing two mats coming from the same video source. I turned them into a gray scale image and I compared the RGB values of both using the get method with parameters (y,x), where the program draws a circle at the changed pixels. However, parts of the mat where there's a definite pixel change are not being recognized. The two images below illustrate what I am talking about. ![image description](/upfiles/15655496731500018.png) ![image description](/upfiles/15655496843901563.png)

opencv-python and multi-threading

$
0
0
Python has GIL that makes multi-threading is less efficient. Opencv-python will release GIL when calling C/C++ function. Therefore, I think that I can use many threads to run tasks with opencv without lost parallel efficiency. For example, I can run a capture thread, a pre-processing thread and a main processing thread. Currently, I am using multiprocessing module, it works but I feel tired because of making communication among processes (frame queue on shared memory, or pipe for sending commands). Could some experienced programmers give me some comments about this problem ? Thanks !

error in command line

$
0
0
my cord // include the librealsense C++ header file #include // include OpenCV header file #include using namespace std; using namespace cv; int main() { //Contruct a pipeline which abstracts the device rs2::pipeline pipe; //Create a configuration for configuring the pipeline with a non default profile rs2::config cfg; //Add desired streams to configuration cfg.enable_stream(RS2_STREAM_COLOR, 640, 480, RS2_FORMAT_BGR8, 30); //Instruct pipeline to start streaming with the requested configuration pipe.start(cfg); // Camera warmup - dropping several first frames to let auto-exposure stabilize rs2::frameset frames; for(int i = 0; i < 30; i++) { //Wait for all configured streams to produce a frame frames = pipe.wait_for_frames(); } //Get each frame rs2::frame color_frame = frames.get_color_frame(); // Creating OpenCV Matrix from a color image Mat color(Size(640, 480), CV_8UC3, (void*)color_frame.get_data(), Mat::AUTO_STEP); // Display in a GUI namedWindow("Display Image", WINDOW_AUTOSIZE ); imshow("Display Image", color); waitKey(0); return 0; } and my command g++ -std=c++11 BGR_sample.cpp -lrealsense2 -lopencv_core -lopencv_highgui -o BGR && ./BGR but error /usr/bin/ld: /tmp/ccOsYVa0.o: undefined reference to symbol '_ZN2cv6String10deallocateEv' //usr/local/lib/libopencv_core.so.3.4: error adding symbols: DSO missing from command line

How to get areas of objects after watershed segmentation?

$
0
0
I have a result of watershed algorithm as follows: [https://ibb.co/9Ypp5WV](/upfiles/15655927707639228.png) How would I find all the separate areas of blobs I have in this result?

using cv::VideoWriter and memory leak

$
0
0
Hi, I using this sample to test cv::VideoWriter.And Memory leak problem happens.How can I release these memory?Is there any other way to save Mat into video file? `here is code:` void writeMP4File() { string videoPath = "./test.mp4"; int frameRate = 6; Mat bmp = imread ("./test_1.png"); cv::Size frame_size(bmps[0].cols,bmps[0].rows); std::string gst_writer = "appsrc ! video/x-raw, format=(string)BGR ! \ videoconvert ! video/x-raw, format=(string)I420 ! \ nvvideoconvert ! video/x-raw(memory:NVMM) ! \ nvv4l2h264enc ! h264parse ! matroskamux ! filesink location=" + videoPath; cv::VideoWriter channelVideoWriter = cv::VideoWriter(gst_writer, cv::VideoWriter::fourcc('a','v','c','1'), frameRate, frame_size, true); int frame = 0; while(frame < 40) { channelVideoWriter.write(bmp); frame++; } channelVideoWriter.release();}

cuda::StereoBM hang up in Nvidia Xavier during compute

$
0
0
Hi, Trying to port a working code from a PC with NVIDIA Geforce GTX 1050 that uses cuda::StereoBM to the Nvidia Xavier. In the PC the code works OK. In the Nvidia Xavier it hung up during the function compute. Using opencv-4.0 compiled with cuda 10.0 according to this script: https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.0.0_Xavier.sh NVIDIA GPU arch is 72 Can anyone please help? Thanks, Gabi

How to convert an RGB image to Boolean array?

$
0
0
Hello, I'm totally new to OpenCV and NumPy. When I load an image using `cv2.imread`, I get a NumPy array with RGBs inside, so every pixel is described as [B G R]. I want to convert this array to boolean one, where every pixel is either black (0) or white (1). Are there any built-in OpenCV functions for this task?

Template matching with zero mean normalized cross-correlation

$
0
0
I wonder how to compute zero mean normalized cross-correlation in opencv? According to [this answer](https://answers.opencv.org/question/6060/template-matching-with-the-cv_tm_ccoeff-algorithm/?answer=6142#post-id-6142) cv::matchTemplate with TM_COEFF_NORMED should do the trick. Answer states that > According to the documentation CV_TM_CCOEFF and CV_TM_CCOEFF_NORMED both subtract the mean from the window and the template however I can not see that mean is subtracted in formula given in the [documentation](https://docs.opencv.org/3.4/de/da9/tutorial_template_matching.html). So is there any built-in way to compute zncc in opencv?

Cannot use Tesseract with OpenCV 4.1.1

$
0
0
Hello there, i followed the official opencv guides to install opencv and tesseract with git bash https://docs.opencv.org/master/d3/d52/tutorial_windows_install.html#tutorial_windows_gitbash_build https://docs.opencv.org/trunk/db/d4c/tutorial_install_tesseract.html I got everything compiled so far and opencv itself works properly but when I try to set up Tesseract with Tesseract::Create() I get these Error Messages: Error in pixReadMemTiff: function not present Error in pixReadMem: tiff: no pix returned Error in pixaGenerateFontFromString: pix not made Error in bmfCreate: font pixa not made Guess that Error pops up because Leptonica is not built with tiff lib, does anyone have a proper description on how i could do so? Thanks in Advance

The results of cv::eigen() are different on Win10 and Ubuntu.

$
0
0
I use the eigenvectors of the local covariance matrix to compute the normals of a point cloud. But I found the results of the function cv::eigen() are different with the same code and data on different OS. The local covariance matrixes are always same, but the signs of the eigenvectors are opposite partially as the image below. ![image description](/upfiles/15656186202449881.jpg) ![image description](/upfiles/1565618665658441.jpg) The first picture is from ubuntu, and the code was compiled by g++. The second picture is from Win10 compiled by VS2017. I want to know why did this happen and how to fix it. Thanks in advance. Here is my code. int computeNormalsPC3d(const Mat& PC, Mat& PCNormals, const int NumNeighbors, const bool FlipViewpoint, const Vec3f& viewpoint) { int i; if (PC.cols!=3 && PC.cols!=6) // 3d data is expected { //return -1; CV_Error(cv::Error::BadImageSize, "PC should have 3 or 6 elements in its columns"); } PCNormals.create(PC.rows, 6, CV_32F); Mat PCInput = PCNormals.colRange(0, 3); Mat Distances(PC.rows, NumNeighbors, CV_32F); Mat Indices(PC.rows, NumNeighbors, CV_32S); PC.rowRange(0, PC.rows).colRange(0, 3).copyTo(PCNormals.rowRange(0, PC.rows).colRange(0, 3)); void* flannIndex = indexPCFlann(PCInput); queryPCFlann(flannIndex, PCInput, Indices, Distances, NumNeighbors); destroyFlann(flannIndex); flannIndex = 0; #if defined _OPENMP #pragma omp parallel for #endif for (i=0; i(i); // compute covariance matrix meanCovLocalPCInd(PCNormals, indLocal, NumNeighbors, C, mu); std::cout << "C: "<< C << std::endl; // eigenvectors of covariance matrix Mat eigVect, eigVal; eigen(C, eigVal, eigVect); std::cout << "eigVect: " << eigVect << std::endl; eigVect.row(2).convertTo(PCNormals.row(i).colRange(3, 6), CV_32F); if (FlipViewpoint) { Vec3f nr(PCNormals.ptr(i) + 3); Vec3f pci(PCNormals.ptr(i)); flipNormalViewpoint(pci, viewpoint, nr); Mat(nr).reshape(1, 1).copyTo(PCNormals.row(i).colRange(3, 6)); } } return 1; } Here is the function cv::eigen in opencv2/core.hpp CV_EXPORTS_W bool eigen(InputArray src, OutputArray eigenvalues, OutputArray eigenvectors = noArray());
Viewing all 41027 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>