why cv2.imwrite() changes the color of pics?

I have the following piece of code: imgs = glob.glob(‘/home/chipin/heart/tray.png’) current_img = io.imread(imgs[0]) cv2.imwrite(‘/home/chipin/heart/01.png’, current_img[0:511,0:511]) The size of picture is 512*512, after being saved, a blue picture turns yellow. It seems that a channel is abandoned. I really don’t know why. Here is the value of current_img: Answer Your problem is in the fact that … Read more

OpenCV not working properly with python on Linux with anaconda. Getting error that cv2.imshow() is not implemented

This is the exact error that I am getting. My OS is Ubuntu 16.10. OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /feedstock_root/build_artefacts/work/opencv-3.1.0/modules/highgui/src/window.cpp, line … Read more

Executing cv::warpPerspective for a fake deskewing on a set of cv::Point

I’m trying to do a perspective transformation of a set of points in order to achieve a deskewing effect: http://nuigroup.com/?ACT=28&fid=27&aid=1892_H6eNAaign4Mrnn30Au8d I’m using the image below for tests, and the green rectangle display the area of interest. I was wondering if it’s possible to achieve the effect I’m hoping for using a simple combination of cv::getPerspectiveTransform … Read more

OpenCV: IplImage versus Mat, which to use?

I’m pretty new to OpenCV (about 2 months now). I have the book Learning OpenCV by Bradski and Kaehler. My question is, if I want to do everything in a 2.0+ manner, when should I use Matrices (Mat) and when should I use IplImage? Bradky’s book states upfront (Preface) that it’s written based on OpenCV … Read more

openCV program compile error “libopencv_core.so.2.4: cannot open shared object file: No such file or directory” in ubuntu 12.04

I compiled and installed openCV 2.4.2 in ubuntu 12.04. Under /usr/local/include I can see the directories /usr/local/opencv and /usr/local/opencv2. Here is the code I wrote: #include <cv.h> #include <highgui.h> #include <iostream> using namespace cv; using namespace std; int main(int argc,char **argv) { Mat image; image = imread(argv[1],1); if(argc != 2 || !image.data) { cout << … Read more

Camera position in world coordinate from cv::solvePnP

I have a calibrated camera (intrinsic matrix and distortion coefficients) and I want to know the camera position knowing some 3d points and their corresponding points in the image (2d points). I know that cv::solvePnP could help me, and after reading this and this I understand that I the outputs of solvePnP rvec and tvec … Read more