[Solved] OpenCV: How do I make a Mat colorized where the Mask is white

I tried switching out and frame in and using frame.copyTo(out, mask) instead of Core.bitwise_and(frame, mask, out) It worked!! Here is my final code: // frame is input, out is output Scalar minValues = new Scalar(RFrom, GFrom, BFrom); Scalar maxValues = new Scalar(RTo, GTo, BTo); Mat mask = new Mat(); Core.inRange(frame, minValues, maxValues, mask); frame.copyTo(out, mask); … Read more

[Solved] What is means by Plotting an Image ?What is the purpose of Image plotting in 2D or 3D? [closed]

You don’t plot an image, you plot data, either in the plain form, or resulting from equations, for images, you just display them, using functions like image Of course, images are in there raw form are data too, but they have special formats. solved What is means by Plotting an Image ?What is the purpose … Read more

[Solved] How draw bounding box on Specfic Area using Opencv python? [closed]

Here is my Python/OpenCV code. I can get the region by a judicious choice of area thresholding. But this is not likely going to be robust for other images. Input: import cv2 import numpy as np # read image img = cv2.imread(“younas.jpg”) # convert img to grayscale gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # median filter gray … Read more

[Solved] How to calculate the number of shapes detected after thresholding

Jeru’s answer is correct for this case. If you have a case with bigger noise where morpholigocal operations won’t take them out, you can make a cutoff with the contour size, something like for contour in contours if cv2.contourArea(contour) > minimal_length before counting 1 solved How to calculate the number of shapes detected after thresholding

[Solved] How to remove the background of an object using OpenCV (Python) [closed]

You mean this? : import cv2 import numpy as np img = cv2.imread(“image.jpg”) hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) mask = cv2.inRange(hsv, (0, 0, 0), (75, 255, 255)) imask = mask > 0 green = np.zeros_like(img, np.uint8) green[imask] = img[imask] cv2.imwrite(“result.png”, green) Output 1 solved How to remove the background of an object using OpenCV (Python) [closed]

[Solved] Getting an error while reading image using cv2.imread() [closed]

You can’t send the whole Pandas dataframe into cv2.imread. You want to access the actual file itself. You also want to append with the image, not a list containing just the image to allow for easier accessing: data = [] for i in range(len(train_data)): img_array = cv2.imread(train_data.loc[i, ‘file’], 1) data.append(img_array) solved Getting an error while … Read more

[Solved] Transpose a 1D byte-wise array to a 2D array

sample #include <stdio.h> #include <string.h> int main(void){ unsigned char a[64*128]; int i,r,c; for(i=0;i<64*128;i++){ a[i]=i; } //not fill unsigned char (*b)[64][128] = (unsigned char (*)[64][128])a; for(r=0;r<64;++r){ for(c=0;c<128;++c){ printf(“%i,”, (*b)[r][c]); } printf(“\n”); } //FILL unsigned char b2[64][128]; memcpy(b2, a, sizeof(b2)); printf(“\nFill ver\n”); for(r=0;r<2;++r){ for(c=0;c<16;++c){ printf(“%i,”, b2[r][c]); } printf(“\n”); } return 0; } solved Transpose a 1D byte-wise … Read more

[Solved] Image Shearing C++

I found some time to work on this. Now I understand what you tried to achieve with the offset computation, but I’m not sure whether yours is correct. Just change all the cv::Vec3b to unsigned char or uchar and load as grayscale, if wanted. Please try this code and maybe you’ll find your error: // … Read more

[Solved] Exporting C++ dll to c# [closed]

[DllImport(@”../data/stasm_dll.dll”)] internal static extern void AsmSearchDll ( [Out] out Int32 pnlandmarks, [Out] out Int32[] landmarks, [In, MarshalAs(UnmanagedType.LPStr)] String image_name, [In, MarshalAs(UnmanagedType.LPStr)] String image_data, [In] Int32 width, [In] Int32 height, [In] Int32 is_color, [In, MarshalAs(UnmanagedType.LPStr)] String conf_file0, [In, MarshalAs(UnmanagedType.LPStr)] String conf_file1 ); IplImage img = cvlib.cvLoadImage(image_name, cvlib.CV_LOAD_IMAGE_COLOR); String imageData = Marshal.PtrToStringAnsi(img.imageData); AsmSearchDll(out nlandmarks, out landmarks, image_name, … Read more