2018-02-05 03:32:34 -0500 edited answer projectPoints fails with points behind the camera You have to find the homogenous 2d points explicitly. Check their z-value. If negative ignore them. Those are the points 2017-12-15 05:03:41 -0500 received badge ● Great Question (source) 2017-10-09 05:13:24 -0500 received badge ● Popular Question (source) 2017-05-11 01:51:31 -0500 answered a question projectPoints fails with points behind the camera You have to find the homogenous 2d points explicitly. Check their z-value. If negative ignore them. Those are the points behind you. In python it looks like this: R, t - current 6dof pose of the camera K - 3x3 Camera matrix D - distortion coefficients xyz - Nx3 3d points proj_mat = np.dot(K, np.hstack((R, t[:, np.newaxis]))) # convert 3D points into homgenous points xyz_hom = np.hstack((xyzs, np.ones((xyzs.shape[0], 1)))) xy_hom = np.dot(proj_mat, xyz_hom.T).T # get 2d coordinates in image [pixels] z = xy_hom[:, -1] xy = xy_hom[:, :2] / np.tile(z[:, np.newaxis], (1, 2)) # undistort - has to be 1xNx2 structure xy = cv2.undistortPoints(np.expand_dims(xy, axis=0), np.eye(3), D).squeeze() # drop all points behind camera xy = xy[z > 0]  2017-02-15 02:51:32 -0500 commented answer GDB pretty printer for showing iplImage or cv::Mat? 2017-02-14 08:09:38 -0500 answered a question GDB pretty printer for showing iplImage or cv::Mat? I had the same problem. You need to install Pillow for Python 3: pip3 install Pillow Then replace the import Image with: from PIL import Image The remaining problem is to convert cv_imshow.py from python 2 to python 3. Here is what I did: -return (seq[pos:pos + size] for pos in xrange(0, len(seq), size)) +return (seq[pos:pos + size] for pos in range(0, len(seq), size)) Also replaced unicode() withstr() However when I type (gdb) source /home/MAGICLEAP/user/gdb-imshow/cv_imshow.py (gdb) cv_imshow img_color I get the following error: CV_8U with 3 channels, 512 rows and 512 cols Python Exception argument must be a sequence: Error occurred in Python command: argument must be a sequence * EDIT *I found a forked version of this script that is compatible with python 3 and works like a charm: https://github.com/cuekoo/GDB-ImageWatch 2017-02-14 08:09:23 -0500 commented answer GDB pretty printer for showing iplImage or cv::Mat? I also tried using 2to3 cv_imshow.py 2016-07-04 01:19:37 -0500 received badge ● Famous Question (source) 2016-06-02 07:52:06 -0500 received badge ● Famous Question (source) 2015-07-31 13:09:35 -0500 received badge ● Notable Question (source) 2015-07-07 06:11:28 -0500 received badge ● Notable Question (source) 2015-04-03 12:56:55 -0500 received badge ● Popular Question (source) 2015-03-16 06:19:47 -0500 received badge ● Popular Question (source) 2015-02-11 12:21:23 -0500 received badge ● Self-Learner (source) 2015-02-11 12:21:23 -0500 received badge ● Necromancer (source) 2014-12-09 13:47:22 -0500 marked best answer Dead link in OpenCV Installation instructions for windows In the list of recommended 3rd party libraries, the first option is a link to Python Libraries It is a dead link and should be fixed. Can this be fixed? Does anyone know what the correct link is? 2014-12-09 13:41:40 -0500 marked best answer Can't link to OpenCV DLL I compiled using Cmake Problem: I compiled OpenCVUsing Cmake and tried to create my own project by following the following Guide This guide worked when linking to OpenCVs precompiled dll's I downloaded from OpenCV.org However I prefer to compile my own Dlls and link to them. Using this method, I compiled OpenCV from Source. I did the following: 1) Define as a system variable OPENCV64_DIR = d:\opencv\build\ You should have in 'opencv' sub-folders named 'build' and 'sources' 2) Add to system Path the following paths for the dlls * %OPENCV64_DIR%\bin\Debug\; * %OPENCV64_DIR%\bin\Release\; 3) Open Visual Studio and create an empty console project 4) convert the project from 32 bit to 64 bit -Right click on solution -> Properties -> Configuration Properties -> Configuration Manager -> Platform -> New -> Choose x64 -> Click on OK to save changes 5) Add in project Properties ->C++ ->Additional Include Directories, the following directories: -$(OPENCV64_DIR)\include; If you compiled OpenCV with TBB and Eigen directories include as well: -$(OPENCV64_DIR)\common\tbb\include; -$(OPENCV64_DIR)\common\Eigen; 6) Add in project Properties ->Linker ->General ->Additional Library Directories: -$(OPENCV64_DIR)\lib\$(Configuration); Note:$(Configuration) stands for Release or Debug according the configuration mode chosen If you compiled OpenCV with TBB include as well: -$(OPENCV64_DIR)common/tbb/lib/intel64/vc12/; -$(OPENCV64_DIR)common/tbb/lib/intel64/vc12/$(Configuration); 7) Add in Properties ->Linker ->Input->Additional Dependencies, the following: For Debug: opencv_calib3d300d.lib;opencv_contrib300d.lib;opencv_core300d.lib;opencv_cuda300d.lib;opencv_cudaarithm300d.lib;opencv_cudabgsegm300d.lib;opencv_cudacodec300d.lib;opencv_cudafeatures2d300d.lib;opencv_cudafilters300d.lib;opencv_cudaimgproc300d.lib;opencv_cudaoptflow300d.lib;opencv_cudastereo300d.lib;opencv_cudawarping300d.lib;opencv_features2d300d.lib;opencv_flann300d.lib;opencv_haartraining_engined.lib;opencv_highgui300d.lib;opencv_imgproc300d.lib;opencv_legacy300d.lib;opencv_ml300d.lib;opencv_nonfree300d.lib;opencv_objdetect300d.lib;opencv_optim300d.lib;opencv_photo300d.lib;opencv_shape300d.lib;opencv_softcascade300d.lib;opencv_stitching300d.lib;opencv_superres300d.lib;opencv_ts300d.lib;opencv_video300d.lib;opencv_videostab300d.lib; For Release: opencv_calib3d300.lib;opencv_contrib300.lib;opencv_core300.lib;opencv_cuda300.lib;opencv_cudaarithm300.lib;opencv_cudabgsegm300.lib;opencv_cudacodec300.lib;opencv_cudafeatures2d300.lib;opencv_cudafilters300.lib;opencv_cudaimgproc300.lib;opencv_cudaoptflow300.lib;opencv_cudastereo300.lib;opencv_cudawarping300.lib;opencv_features2d300.lib;opencv_flann300.lib;opencv_haartraining_engined.lib;opencv_highgui300.lib;opencv_imgproc300.lib;opencv_legacy300.lib;opencv_ml300.lib;opencv_nonfree300.lib;opencv_objdetect300.lib;opencv_optim300.lib;opencv_photo300.lib;opencv_shape300.lib;opencv_softcascade300.lib;opencv_stitching300.lib;opencv_superres300.lib;opencv_ts300.lib;opencv_video300.lib;opencv_videostab300.lib; After doing all of this, I get the following Error: main.obj : error LNK2019: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd@cv@@YAHPEAHH@Z) referenced in function "public: void __cdecl cv::Mat::release(void)" (?release@Mat@cv@@QEAAXXZ)  From the following code: #include #include #include "opencv2\opencv.hpp" using namespace std; using namespace cv; /** @function main */ int main(int argc, const char** argv) { cout << "Hello world x64" << endl; Mat image; String inputName; return 0; }  What does work, is compiling the code by actually adding the opencv projects to my solution like in OpenCV's examples. See EXAMPLE cout_mat This is time consuming and compiles the modules every time I compile my project. Any better ideas? What am I missing? 2014-12-09 13:11:18 -0500 marked best answer Open CV's HoughCircles() is ~1000 times faster than my version I tried to write my own version of Hough Transform for circles. Even after a few cycles of optimization I could not get close the performance of OpenCV. The code can be found here: https://bitbucket.org/YontanSimson/opencv-projects/src/e504c2a4bd4043003456c63a44e440b96ae86050/HoughCircle/?at=master My CPU is an Intel 8 core i7-3770 CUP @ 3.4GHz My Display Adapter is an Intel HD Graphics 4000 How do they manage to get good results so fast? 2014-06-10 10:50:24 -0500 commented answer Object detection without nonfree I see. So your problem is with the descriptor not the Keypoint detector. You have free descriptors like Freak, BRIEF and FAST. Which one did you try? 2014-06-09 03:18:21 -0500 answered a question Object detection without nonfree I also tried Orb instead of SURF as Keypoint detector and found the problem with using ORB is it doesn't have very good non-maximal suppression. It tends to return Keypoints clumped very closely together. Fortunately for me I can use nonfree since it is not a commercial product. What other free Keypoint detectors have you tried? Besides for ORB there are BRISK, StarDetector, GFTTDetector. Why not give either one of these a shot? 2014-06-02 06:17:10 -0500 commented answer Guide for installing and compiling OpenCV with CMake and Visual Studio 2013 I am using Window 7 so I haven't tried in Windows 8. Have you tried all of the with the latest Cmake-Gui? I haven't heard about anyone having problems before. 2014-05-28 00:41:03 -0500 commented answer Where is OpenMP used in OpenCV? Here is a short guide on how to manually compile OpenCV with Intel's TBB library 2014-05-26 10:05:56 -0500 asked a question OpenCV's ORB feature detector tend form clumps around certain areas Which makes it necessary to follow up with non-maximal suppression. In comparison Shi-AndTomasi's GFTT behaves very well. Is this a drawback of the method or I am not using the ORB feature detection correctly? Here is the code I used for initializing the detector: OrbFeatureDetector detector(1000, 1.2f, 3, 20); 2014-05-26 09:59:55 -0500 commented answer reconfigure to newer version If you are happy with the answer, please mark the accept it as the correct answer :) 2014-05-25 01:06:49 -0500 answered a question How to get sensor physical size (openCV)? cv::VideoCapture cap; if (!cap.isOpened()) // check if we succeeded CV_Assert("Can't open Web-Cam"); double CamHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); double CamWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH);  Check out the documentation for getting webcam properties 2014-05-25 00:58:30 -0500 commented answer reconfigure to newer version This usually means one of three mistakes. Either opencv_calib3d242d.lib does not exist because you are using a different version. Likely the file you wish to have in Configuration Property pages->Linker->Input->Additional dependencies is opencv_calib3d249d.lib. Or you did not define the correct directories for additional libraries. Check the definitions in the Configuration Property pages->Linker->General->Additional Library directories Another possible error is your project definition might be x86 while the directory you refer to is x64 or visa versa. Not that in the precompiled libraries you need to choose both your correct Visual Studio version(v10/v11) AND architecture type(x86/x64). 2014-05-24 14:50:21 -0500 answered a question multiple webcams VC++ One simple method is to try open webcams until you fail. The number of successes is the number of webcams. How is how I would do this: #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" /** @function main */ int main(int argc, const char** argv) { int numOfWebCams = 0; cv::VideoCapture cap[MAX_NUM_OF_CAMERAS]; cv::Mat frame; for (size_t i = 0; i < MAX_NUM_OF_CAMERAS; i++) { cap[i].open(i); bool bSuccess = true; if (!cap[i].isOpened()) // check if we succeeded bSuccess &= false; bSuccess &= cap[i].read(frame); // read a new frame from video if (!bSuccess) //if not success, break loop { std::cout << "The number of active webcams is: " << numOfWebCams << std::endl; break; } else ++numOfWebCams; } return 0; }  2014-05-24 13:42:38 -0500 answered a question General steps of linking openCV OpenCV is cross platform so you first should state which platform it is that you wish to compile and develop your code. I assume you are aiming at developing code for Windows OS. For all OSs here is the link. For Windows you have 3 basic options: One option is to download cygwin which is nice IF you are familiar with Unix environment. Then you compile the code as if you are working in Unix. If you are not familiar with Unix, you might face a steep learning curve. The other option is to link OpenCV precompiled binaries to your code using Visual Studio. You can find the pre-compiled binaries here. Documentation for linking to pre-compiled binaries can be found here. This is the easiest option for beginners. You can also download the source code from github and compile it yourself. Here is simple tutorial on how to do this 2014-05-24 12:39:52 -0500 answered a question reconfigure to newer version You should start by downloading the newest version which currently 2.4.9 from this link Make sure to download it into a new directory preferably with the version number as a suffix. e.g: d:\opencv249 Define as system variable OPENCV_DIR249 = d:\opencv249 (my recomendation). Also see this explanation on how to do it. Then all you have left to do is to learn to link your new versions libraries and dll's to your code in Visual Studio 2010 as explained here. Good luck! 2014-05-15 09:00:26 -0500 received badge ● Necromancer (source) 2014-05-15 08:58:26 -0500 received badge ● Necromancer (source) 2014-05-15 08:53:11 -0500 answered a question Best features to track fish underwater Using back projection might work. The basic idea is to transfer the reference fish image from rgb to HSV Calculate the HS 2D histogram of the reference fish image. Turn the histogram into a probability by normalizing it's sum to 1 Convert the query image into HSV as well For each pixel in query image find it's appropriate bin in the HS histogram. For each pixel create an image of the probabilities taken from histogram. Here is a good explanation 2014-05-15 08:41:01 -0500 answered a question Featuretracker: OpenCV has been compiled without SIFT support This worked for me on version 2.4.9. I had the exact same problem trying to run the hybridtracking example Goto opencv_contrib module->$(OPENCV_DIR)\sources\modules\contrib\src\featuretracker.cpp Replace these lines: #ifdef HAVE_OPENCV_NONFREE #include "opencv2/nonfree/nonfree.hpp" static bool makeUseOfNonfree = initModule_nonfree(); #endif  With the following: #define HAVE_OPENCV_NONFREE #ifdef HAVE_OPENCV_NONFREE #include "opencv2/nonfree/nonfree.hpp" static bool makeUseOfNonfree = cv::initModule_nonfree(); #endif  2014-05-13 09:13:45 -0500 commented answer HowTo split YCrCb into Y, Cr and Cb? Another option I can offer is to convert this YUV422 Image which is actually in YV12 format into RGB then Split it. Or split it after converting back to YCbCr 4:4:4 format. Mat YUV444, GRB; vector<Mat> SplitYCbCr; cvtColor(frame, GRB, COLOR_YUV2BGR_UYVY); cvtColor(GRB, YUV444, COLOR_BGR2YCrCb); split(YUV444, SplitYCbCr);  Note: When upsampling the Chroma channels you need to pay attention whether source is video of Jpeg image. Both use 422 formats widely but define them differently. 2014-05-13 07:50:00 -0500 commented answer HowTo split YCrCb into Y, Cr and Cb? I understand. This is YUV422 format. For every pixel of Luma(Y) you have one Chroma alternating between CbCr. What you need to to do is first separate Luma from Chroma. Then split the two Chroma channels. Then upsample by x2 the Chroma Channels horizontally, to turn them into the same size as as the Luma (presuming this is what you want).