image-processing

Detect number of rows and columns in table image with OpenCV

天涯浪子 提交于 2021-02-18 17:12:40
问题 How can we get the number of rows and columns in an Image table via Opencv. Code for getting boxes in table which I am getting right contours, hierarchy = cv2.findContours(img_final_bin, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) def sort_contours(cnts, method="left-to-right"): # initialize the reverse flag and sort index reverse = False i = 0 # handle if we need to sort in reverse if method == "right-to-left" or method == "bottom-to-top": reverse = True # handle if we are sorting against the y

Detect number of rows and columns in table image with OpenCV

社会主义新天地 提交于 2021-02-18 17:07:13
问题 How can we get the number of rows and columns in an Image table via Opencv. Code for getting boxes in table which I am getting right contours, hierarchy = cv2.findContours(img_final_bin, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) def sort_contours(cnts, method="left-to-right"): # initialize the reverse flag and sort index reverse = False i = 0 # handle if we need to sort in reverse if method == "right-to-left" or method == "bottom-to-top": reverse = True # handle if we are sorting against the y

Is there anyway (commandline tools) to calculate MD5 hash for .NEF (also .CR2, .TIFF) regardless any metadata?

99封情书 提交于 2021-02-18 12:46:16
问题 Is there anyway (commandline tools) to calculate MD5 hash for .NEF (also .CR2, .TIFF) regardless any metadata, e.g. EXIF, IPTC, XMP and so on? The MD5 hash should be same once we update any metadata inside the image file. I searched for a while, the closest solution is: exiftool test.nef -all= -o - -m | md5 but 'exiftool -all=' still keeps a set of EXIF tags in the output file. The MD5 hash can be changed if I update remaining tags. 回答1: ImageMagick has a method for doing exactly this. It is

Is there anyway (commandline tools) to calculate MD5 hash for .NEF (also .CR2, .TIFF) regardless any metadata?

一笑奈何 提交于 2021-02-18 12:46:14
问题 Is there anyway (commandline tools) to calculate MD5 hash for .NEF (also .CR2, .TIFF) regardless any metadata, e.g. EXIF, IPTC, XMP and so on? The MD5 hash should be same once we update any metadata inside the image file. I searched for a while, the closest solution is: exiftool test.nef -all= -o - -m | md5 but 'exiftool -all=' still keeps a set of EXIF tags in the output file. The MD5 hash can be changed if I update remaining tags. 回答1: ImageMagick has a method for doing exactly this. It is

How to find the distance between two concentric contours, for different angles?

為{幸葍}努か 提交于 2021-02-18 08:02:48
问题 I have an image with two contours, where one contour is always 'inside' another. I want to find the distance between the two contours for 90 different angles (meaning, distance at every 4 degrees). How do I go about doing it? Here's an example image: Thank you! 回答1: In the following code, I have just given you the example for the vertical line, the rest can be obtained by rotating the line. Result looks like this, instead of drawing you can use the coordinates for distance calculation. import

Using a PNG image as mask for GrabCut

独自空忆成欢 提交于 2021-02-18 07:58:10
问题 I have a png image with green and red lines and transparent background, which I need to use is as a mask for executing GrabCut. But I get unexpected results. Here's my code: //find the mask Mat mask; mask.create( image.size(), CV_8UC1); mask.setTo(Scalar::all(GC_BGD)); Mat maskImg = imread("messi5.png"); for(int i=0; i<maskImg.cols; i++) for(int j=0; j<maskImg.rows; j++) { //if it's red, make it white if ((int)maskImg.at<cv::Vec3b>(j,i)[0]==0 && (int)maskImg.at<cv::Vec3b>(j,i)[1] == 0 && (int

how to segment the connected area based on depth color in opencv

拜拜、爱过 提交于 2021-02-18 06:33:38
问题 I have a picture like , which i need to segment the picture into 8 blocks. I have tried this threshold method img_gray = cv2.imread(input_file,cv2.IMREAD_GRAYSCALE) ret,thresh = cv2.threshold(img_gray,254,255,cv2.THRESH_BINARY) = kernel = np.array(cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3), (-1, -1))) img_open = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel) cv2.imshow('abc',img_open) ret1,thresh1 = cv2.threshold(img_open,254,255,cv2.THRESH_BINARY_INV) # contours, hierarchy = cv2

Align two images in OpenCV

不问归期 提交于 2021-02-18 05:18:29
问题 I have two images (see below). These images represent the contours of a pair of cables and were captured using laser based 3D triangulation. The first image is captured with the left camera, while the second one with the right camera. As can be seen, these images are partially overlapping. The left part on the first image partly corresponds to the left part on the second image. The same holds for the right part. I want to merge these two images into one image so that the corresponding parts

Invalid number of channels in input image error using OpenCV

∥☆過路亽.° 提交于 2021-02-17 06:58:06
问题 cv2.error: OpenCV(4.2.0) c:\projects\opencv python\opencv\modules\imgproc\src\color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function '__cdecl cv::impl::`anonymous- namespace'::CvtHelper<struct cv::impl::`anonymous namespace'::Set<3,4,-1>,struct cv::impl::A0xe227985e::Set<1,-1,-1>,struct cv::impl::A0xe227985e::Set<0,2,5>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int) > Invalid number of channels in input image: > 'VScn::contains(scn)' > where >

Invalid number of channels in input image error using OpenCV

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-17 06:58:04
问题 cv2.error: OpenCV(4.2.0) c:\projects\opencv python\opencv\modules\imgproc\src\color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function '__cdecl cv::impl::`anonymous- namespace'::CvtHelper<struct cv::impl::`anonymous namespace'::Set<3,4,-1>,struct cv::impl::A0xe227985e::Set<1,-1,-1>,struct cv::impl::A0xe227985e::Set<0,2,5>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int) > Invalid number of channels in input image: > 'VScn::contains(scn)' > where >