opencv3.0

What is the cv2.cv replacement in OpenCV3?

北战南征 提交于 2019-11-28 18:41:34
I'm using OpenCV3, and with the python bindings there is no cv2.cv module: In [1]: import cv2 In [2]: from cv2 import cv --------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-2-15a6578c139c> in <module>() ----> 1 from cv2 import cv ImportError: cannot import name cv However, I have some legacy code of the form: hsv_im = cv2.cvtColor(image, cv2.cv.CV_BGR2HSV) When running this, I get the error: In [7]: hsv_im = cv2.cvtColor(image, cv2.cv.CV_BGR2HSV) ----------------------------------------------------------------

OpenCV 3.0 Can't load neural network

时间秒杀一切 提交于 2019-11-28 13:53:27
I need to use a neural network in my OpenCV (version 3.0) project. I've created and trained neural network and it works, but if I want to load neural network from YML file, it doesn't predict. This is a code where I creat, train and save my neural network: FileStorage fs("nn.yml", FileStorage::WRITE); int input_neurons = 7; int hidden_neurons = 100; int output_neurons = 5; Ptr<TrainData> train_data = TrainData::loadFromCSV("data.csv", 10, 7, 12); Ptr<ANN_MLP> neural_network = ANN_MLP::create(); neural_network->setTrainMethod(ANN_MLP::BACKPROP); neural_network->setBackpropMomentumScale(0.1);

OpenCV imwrite gives washed-out result for jpeg images

落爺英雄遲暮 提交于 2019-11-28 12:19:03
I am using OpenCV 3.0 and whenever I read an image and write it back the result is a washed-out image. code: cv::Mat img = cv::imread("dir/frogImage.jpg",-1); cv::imwrite("dir/result.jpg",img); Does anyone know whats causing this? Original: Result: You can try to increase the compression quality parameter as shown in OpenCV Documentation of cv::imwrite : cv::Mat img = cv::imread("dir/frogImage.jpg",-1); std::vector<int> compression_params; compression_params.push_back(CV_IMWRITE_JPEG_QUALITY); compression_params.push_back(100); cv::imwrite("dir/result.jpg",img, compression_params); Without

OpenCV: AttributeError: module 'cv2' has no attribute 'face'

为君一笑 提交于 2019-11-28 10:04:04
问题 I am creating a face recognition system using Python and OpenCV on these versions: Python 3.6.2 :: Anaconda custom (64-bit) Anaconda 4.3.23 OpenCV 3.3.0 When I try to train the face recognizer: face_recognizer = cv2.face.createLBPHFaceRecognizer() I get this error: AttributeError: module 'cv2' has no attribute 'face' Update: I've tried to do this: pip install opencv_python‑3.3.0+contrib‑cp36‑cp36m‑win_amd64.whl Also: conda install -c menpo opencv3=3.3.0 And I still have the error. 回答1: The

BGR to HSV and back again

霸气de小男生 提交于 2019-11-28 09:27:40
问题 The documentation does not seem to explain what the expected range of the input is for an HSV->BGR conversion. Here is some example code where I am trying to get back the original BGR value after converting it to HSV. Does anyone know which scaling is expected? #include <iostream> #include <opencv2/opencv.hpp> cv::Vec3b HSVtoBGR(const cv::Vec3f& hsv) { cv::Vec3f hsvAdjusted = hsv; // If we use this directly, the output is (0,0,1) which is very wrong //hsvAdjusted[0] *= 360.; // If we do this

OpenCV 3.x only contains one lib - opencv_world.lib?

别说谁变了你拦得住时间么 提交于 2019-11-28 09:02:49
I'm trying to update my OpenCV version from 2.4.9 to the newest version, 3.10. I downloaded the Windows binary from here , having navigated there from the official OpenCV site. I then ran the installer, but the opencv\build\x64\vc12\lib directory only contained a couple files: opencv_world310.lib opencv_world310d.lib OpenCVConfig.cmake OpenCVModules.cmake OpenCVModules-debug.cmake OpenCVModules-release.cmake In the past editions though, this directory used to contain the required libraries, like opencv_calib3d249d.lib, opencv_contrib249d.lib, opencv_core249d.lib, etc. I imagine there's

openCV 3.0.0 cv::vector missing

感情迁移 提交于 2019-11-28 07:47:28
问题 I'm upgrading from opencv 2.4.11 to 3.0.0 I have used cv::vector in my code <br> but now I get the error vector in not a member of 'cv' I will start using std::vector instead <br> however I can't find anywhere was it removed or just moved to another header file? 回答1: In OpenCV prior to 3.0, you can see at the beginning of core.hpp that OpenCV is using std::vector internally: #ifndef __OPENCV_CORE_HPP__ #define __OPENCV_CORE_HPP__ ... #include <vector> ... /*! \namespace cv Namespace where all

OpenCV 3 Tracker won't work after reinitialization

旧街凉风 提交于 2019-11-28 07:41:17
问题 I have issue using OpenCV 3 tracking module for tracking. It behaves same, either I use interface class (cv::Tracker) or class with implementation (like cv::TrackerMedianFlow or cv::TrackerMIL, etc). Sample is a bit modified sample from OpenCV sample folder After correct creation Ptr<Tracker> tracker = Tracker::create( tracker_algorithm ); if ( tracker == NULL ) { std::cout << "***Error in the instantiation of the tracker...***\n"; return -1; } initialization works just fine if ( !tracker-

How to optimize this image iteration in numpy?

▼魔方 西西 提交于 2019-11-28 06:48:22
问题 I'm using this code to detect green color in the image. The problem is this iteration is really slow. How to make it faster? If it is using numpy, How to do it in numpy way? def convertGreen(rawimg): width, height, channels = rawimg.shape size = (w, h, channels) = (width, height, 1) processedimg = np.zeros(size, np.uint8) for wimg in range(0,width): for himg in range(0,height): blue = rawimg.item(wimg,himg,0) green = rawimg.item(wimg,himg,1) red = rawimg.item(wimg,himg,2) exg = 2*green-red

Shape Transformers and Interfaces OpenCV3.0

北城余情 提交于 2019-11-28 06:16:29
问题 I was trying to make use of the new Shape Transformers and Interfaces of OpenCV3.0. Unfortunately it doesn't work as expected. To ensure not making any fancy warps and getting strange results cause of that reason I initialized a transformation where nothing at all should happen. But output of the transformation for a testpoint is always [0,0] and the warped image is always completley gray. Any suggestions what could be wrong are welcome. int main(void){ Mat img1 = imread("C:\\opencv\\sources\