ezdxfを使って入力画像からエッジを検出したDXFデータを作ることができたのですが、dxfデータの寸法がどのように決定されているのか分かりません。調べてみても、かような情報を得る事が出来ませんでした。dxfデータの読み取りにはeDrwingsを使っています。
どのように寸法が決定されるのか、ご教授いただけると幸いです。また、その寸法を変更する事ができる場合、その方法を教えていただけるとありがたいです。
Python
1import numpy as np 2import cv2 3from matplotlib import pyplot as plt 4import ezdxf 5 6img = cv2.imread("/Users/mutaguchitakuma/Desktop/test010.jpg") 7img2 = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) 8 9dst = cv2.fastNlMeansDenoisingColored(img2,None,10,10,7,21) 10 11blue_min = np.array([140, 0, 0], np.uint8) 12blue_max = np.array([255, 255, 255], np.uint8) 13 14mask_blue = cv2.inRange(dst, blue_min, blue_max) 15img3 = cv2.bitwise_not(mask_blue) 16plt.imshow(cv2.cvtColor(mask_blue, cv2.COLOR_GRAY2RGB)) 17 18 19_, contours, hierarchy = cv2.findContours(img3, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) 20contours = [np.squeeze(cnt, axis=1) for cnt in contours] 21 22size = img.shape 23h = size[0] 24w = size[1] 25 26imgnew = np.zeros((h, w, 3), np.uint8) 27img4 = cv2.drawContours(imgnew, contours, 1, (0,255,0), 3) 28 29print("contours=",len(contours), "hierarchy=",len(hierarchy) ) 30#print(contours[1]) 31 32plt.imshow(img4) 33plt.show 34 35cv2.imwrite('out.jpg', img4) 36 37ctr = contours[1] 38 39dwg = ezdxf.new('R2010') #create a new DXF R2010 drawing, official DXF version name: 'AC1024' 40msp = dwg.modelspace() #add new entities to the model space 41dwg.layers.new(name='MyLines', dxfattribs={'color': 3}) # 3=Green 42 43for i in range(len(ctr)): 44 n = i+1 45 if n >= len(ctr): 46 n = 0 47 msp.add_line(ctr[i],ctr[n], dxfattribs={'layer': 'MyLines'}) # add a LINE entity 48 #print(ctr[i],'->',ctr[n]) 49 50dwg.saveas('line.dxf')

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/17 10:14