OpenCV

OpenCV with RGB 16bits

本小妞迷上赌 提交于 2021-01-28 16:25:12
问题 I have a data (unsigned char*) with RGB 16 bits format R:5 G:6 B:5 How can I set this data to IplImage format? I can start with: unsigned char* data = ...data...; IplImage *img = cvCreateImage(cvSize(800,480), IPL_DEPTH_8U, 3); // Should it be 16? cvSetData(img,data,800*2); // Here is where I am not sure 回答1: You are going to need to convert from IPL_DEPTH_16U (single-channel) to IPL_DEPTH_8U (three-channel). Below is some code I wrote up quickly (this should work, but I don't have a 565

opencv_createsamples: command not found ubuntu

爷,独闯天下 提交于 2021-01-28 14:24:07
问题 I am following Creating your own Haar Cascade OpenCV Python Tutorial But when I get to making the samples I get opencv_createsamples: command not found I am using this to create the samples opencv_createsample -img img.jpg -bg bg.txt -info info/info.lst -pngoutput info -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 573 but I know the command exists because when I do man opencv_createsamples it pulls up the man page. I am using ubuntu 20.04.1 回答1: I have also met this same problem while

Drawing inscribing circle into thresholded image

杀马特。学长 韩版系。学妹 提交于 2021-01-28 12:47:42
问题 I am trying to draw max inscribing circle into thresholded (contoured) image to extract the palmar part of the hand. Original image 1: My code: import cv2 import imutils pathToThePhoto = 'hand.jpg' #Load the photo img = cv2.imread(pathToThePhoto) #Converting the image into gray colour gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #Thresholding the image thresh = cv2.threshold(gray, 100 , 255, cv2.THRESH_BINARY)[1] cv2.imshow("thresholded", thresh) #Find contours in thresholded image cnts = cv2

Drawing inscribing circle into thresholded image

自闭症网瘾萝莉.ら 提交于 2021-01-28 12:44:48
问题 I am trying to draw max inscribing circle into thresholded (contoured) image to extract the palmar part of the hand. Original image 1: My code: import cv2 import imutils pathToThePhoto = 'hand.jpg' #Load the photo img = cv2.imread(pathToThePhoto) #Converting the image into gray colour gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #Thresholding the image thresh = cv2.threshold(gray, 100 , 255, cv2.THRESH_BINARY)[1] cv2.imshow("thresholded", thresh) #Find contours in thresholded image cnts = cv2

Iterate over regions and take mean pixel value in OpenCV?

时间秒杀一切 提交于 2021-01-28 11:50:38
问题 So Im basically trying to divide up a gray scale image (in this case 32x32) by resizing the initial image. Once the "regions" are divided up, I need to take the mean pixel value of each one and then add to a string a 1, 0, or X. For example: "Region (3, 19) has a mean value of 21 so that's a 1". I think I have most of the logic down but shouldn't, in theory, the output recreate the image in the form of 1s, 0s, and Xs? I feel like my math is wrong on the for loops maybe? Remember, all Im

How to access a 3 dimensional Matrix elements?

爷,独闯天下 提交于 2021-01-28 11:49:05
问题 How do I index through a 3 dimensional matrix? I have this code and I know that the string inside cycles is wrong. Any suggestions on doing it in proper way. Mat frame_; cvtColor(frame, frame_, CV_BGR2HSV); int size[3] = { capture_box_dim*capture_box_count, capture_box_dim, 3}; Mat ROI = Mat::zeros (3, size, frame_.type()); for (int i = 0; i < capture_box_count; i++) { for (int j = i*capture_box_dim, int k = box_pos_y[i], int l = 0, int t = box_pos_x[i]; j < i*capture_box_dim + capture_box

Create video from image.ppm c++

孤者浪人 提交于 2021-01-28 11:37:41
问题 I don't how to create a video with image sequences. My image are save in file (the extension is .ppm) , the type of the file is so FILE * not a Mat like I can found in others topics who someone want to create a video too but he uses Mat type. For example, i save 5 images in 5 files (one image per file so) and i want to create a video with the order of the image (image0 to image4) and one sec in the video match with one image. Here my code : #include <fstream> #include <iostream> #include

Linking errors for Qt and cvv when building OpenCV in Windows 10

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-28 11:06:15
问题 I am trying to build OpenCV according to these instructions. After generating with CMake I opened OpenCV.sln in the build folder, switched to Release mode and built ALL_BUILD successfully. But when I try to build the INSTALL option under CMake, I get errors like this: Error LNK2001 unresolved external symbol "public: virtual struct QMetaObject const * __cdecl cvv::qtutil::Signal::metaObject(void)const " Error LNK2019 unresolved external symbol "public: void __cdecl cvv::qtutil::ZoomableImage:

OpenCV+Python getting this error when trying to run the code on bigger images

坚强是说给别人听的谎言 提交于 2021-01-28 10:04:48
问题 I am getting this error when running my code through a set of big images of 5472 x 3648 dimension(4.4mb) . The code is working fine when my images were around 1437 x 1243 dimension, I can run through all images and save it. Notice: You can see with bigger images, I still managed to run the first file and save it to 1771, it only shown error and stop the run halfway through 1772. Is there anyway which I can process my images using this algorithm without needing to resize the images dimension?

Click image 1 time, get position and destroy window OpenCv

穿精又带淫゛_ 提交于 2021-01-28 09:50:57
问题 Is there a simple way to open an image using OpenCv, and keep it open until it is clicked, then return the pixel coordinate and destroy the image, almost like using WaitKey() just with a return, and click as trigger? 回答1: This should do what you want: #!/usr/bin/env python3 import cv2 import numpy as np def onClick(event,x,y,flags,param): """Called whenever user left clicks""" global Running if event == cv2.EVENT_LBUTTONDOWN: print(f'I saw you click at {x},{y}') Running = False # Create