Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@kmmn1120

numpyバイナリファイルの座標データからplot(自分用)

More than 1 year has passed since last update.

import math
import pylab as plt
import json
import matplotlib.pyplot as plt
import math
import numpy as np

rotated_face = np.load(
'C:/Users/Each directri')

print(rotated_face)

plot_style = dict(marker='o',
color="red",
markersize=4,
linestyle='-',
lw=2)

x0 = rotated_face[0,0]
y0 = rotated_face[0,1]
x1 = rotated_face[1,0]
y1 = rotated_face[1,1]
x2 = rotated_face[2,0]
y2 = rotated_face[2,1]
x3 = rotated_face[3,0]
y3 = rotated_face[3,1]
x4 = rotated_face[4,0]
y4 = rotated_face[4,1]
x5 = rotated_face[5,0]
y5 = rotated_face[5,1]
x6 = rotated_face[6,0]
y6 = rotated_face[6,1]
x7 = rotated_face[7,0]
y7 = rotated_face[7,1]
x8 = rotated_face[8,0]
y8 = rotated_face[8,1]
x9 = rotated_face[9,0]
y9 = rotated_face[9,1]
x10 = rotated_face[10,0]
y10 = rotated_face[10,1]
x11 = rotated_face[11,0]
y11 = rotated_face[11,1]
x12 = rotated_face[12,0]
y12 = rotated_face[12,1]
x13 = rotated_face[13,0]
y13 = rotated_face[13,1]
x14 = rotated_face[14,0]
y14 = rotated_face[14,1]
x15 = rotated_face[15,0]
y15 = rotated_face[15,1]
x16 = rotated_face[16,0]
y16 = rotated_face[16,1]
x17 = rotated_face[17,0]
y17 = rotated_face[17,1]
x18 = rotated_face[18,0]
y18 = rotated_face[18,1]
x19 = rotated_face[19,0]
y19 = rotated_face[19,1]
x20 = rotated_face[20,0]
y20 = rotated_face[20,1]
x21 = rotated_face[21,0]
y21 = rotated_face[21,1]
x22 = rotated_face[22,0]
y22 = rotated_face[22,1]
x23 = rotated_face[23,0]
y23 = rotated_face[23,1]
x24 = rotated_face[24,0]
y24 = rotated_face[24,1]
x25 = rotated_face[25,0]
y25 = rotated_face[25,1]
x26 = rotated_face[26,0]
y26 = rotated_face[26,1]
x27 = rotated_face[27,0]
y27 = rotated_face[27,1]
x28 = rotated_face[28,0]
y28 = rotated_face[28,1]
x29 = rotated_face[29,0]
y29 = rotated_face[29,1]
x30 = rotated_face[30,0]
y30 = rotated_face[30,1]
x31 = rotated_face[31,0]
y31 = rotated_face[31,1]
x32 = rotated_face[32,0]
y32 = rotated_face[32,1]
x33 = rotated_face[33,0]
y33 = rotated_face[33,1]
x34 = rotated_face[34,0]
y34 = rotated_face[34,1]
x35 = rotated_face[35,0]
y35 = rotated_face[35,1]
x36 = rotated_face[36,0]
y36 = rotated_face[36,1]
x37 = rotated_face[37,0]
y37 = rotated_face[37,1]
x38 = rotated_face[38,0]
y38 = rotated_face[38,1]
x39 = rotated_face[39,0]
y39 = rotated_face[39,1]
x40 = rotated_face[40,0]
y40 = rotated_face[40,1]
x41 = rotated_face[41,0]
y41 = rotated_face[41,1]
x42 = rotated_face[42,0]
y42 = rotated_face[42,1]
x43 = rotated_face[43,0]
y43 = rotated_face[43,1]
x44 = rotated_face[44,0]
y44 = rotated_face[44,1]
x45 = rotated_face[45,0]
y45 = rotated_face[45,1]
x46 = rotated_face[46,0]
y46 = rotated_face[46,1]
x47 = rotated_face[47,0]
y47 = rotated_face[47,1]
x48 = rotated_face[48,0]
y48 = rotated_face[48,1]
x49 = rotated_face[49,0]
y49 = rotated_face[49,1]
x50 = rotated_face[50,0]
y50 = rotated_face[50,1]
x51 = rotated_face[51,0]
y51 = rotated_face[51,1]
x52 = rotated_face[52,0]
y52 = rotated_face[52,1]
x53 = rotated_face[53,0]
y53 = rotated_face[53,1]
x54 = rotated_face[54,0]
y54 = rotated_face[54,1]
x55 = rotated_face[55,0]
y55 = rotated_face[55,1]
x56 = rotated_face[56,0]
y56 = rotated_face[56,1]
x57 = rotated_face[57,0]
y57 = rotated_face[57,1]
x58 = rotated_face[58,0]
y58 = rotated_face[58,1]
x59 = rotated_face[59,0]
y59 = rotated_face[59,1]
x60 = rotated_face[60,0]
y60 = rotated_face[60,1]
x61 = rotated_face[61,0]
y61 = rotated_face[61,1]
x62 = rotated_face[62,0]
y62 = rotated_face[62,1]
x63 = rotated_face[63,0]
y63 = rotated_face[63,1]
x64 = rotated_face[64,0]
y64 = rotated_face[64,1]
x65 = rotated_face[65,0]
y65 = rotated_face[65,1]
x66 = rotated_face[66,0]
y66 = rotated_face[66,1]
x67 = rotated_face[67,0]
y67 = rotated_face[67,1]

輪郭の描画

plt.plot([x0, x1], [y0, y1],
[x1, x2], [y1, y2],
[x2, x3], [y2, y3],
[x3, x4], [y3, y4],
[x4, x5], [y4, y5],
[x5, x6], [y5, y6],
[x6, x7], [y6, y7],
[x7, x8], [y7, y8],
[x8, x9], [y8, y9],
[x9, x10], [y9, y10],
[x10, x11], [y10, y11],
[x11, x12], [y11, y12],
[x12, x13], [y12, y13],
[x13, x14], [y13, y14],
[x14, x15], [y14, y15],
[x15, x16], [y15, y16], 'k-', **plot_style)

眉の描画

plt.plot([x17, x18], [y17, y18],
[x18, x19], [y18, y19],
[x19, x20], [y19, y20],
[x20, x21], [y20, y21], 'k-', **plot_style)

plt.plot([x22, x23], [y22, y23],
[x23, x24], [y23, y24],
[x24, x25], [y24, y25],
[x25, x26], [y25, y26], 'k-', **plot_style)

鼻の描画

plt.plot([x27, x28], [y27, y28],
[x28, x29], [y28, y29],
[x29, x30], [y29, y30], 'k-', **plot_style)

plt.plot([x31, x32], [y31, y32],
[x32, x33], [y32, y33],
[x33, x34], [y33, y34],
[x34, x35], [y34, y35], 'k-', **plot_style)

目の描画(輪郭)

plt.plot([x36, x37], [y36, y37],
[x37, x38], [y37, y38],
[x38, x39], [y38, y39],
[x39, x40], [y39, y40],
[x40, x41], [y40, y41],
[x41, x36], [y41, y36], 'k-', **plot_style)

plt.plot([x42, x43], [y42, y43],
[x43, x44], [y43, y44],
[x44, x45], [y44, y45],
[x45, x46], [y45, y46],
[x46, x47], [y46, y47],
[x47, x42], [y47, y42], 'k-', **plot_style)

口の描

plt.plot([x48, x49], [y48, y49],
[x49, x50], [y49, y50],
[x50, x51], [y50, y51],
[x51, x52], [y51, y52],
[x52, x53], [y52, y53],
[x53, x54], [y53, y54],
[x54, x55], [y54, y55],
[x55, x56], [y55, y56],
[x56, x57], [y56, y57],
[x57, x58], [y57, y58],
[x58, x59], [y58, y59],
[x59, x48], [y59, y48], 'k-', **plot_style)

plt.plot([x60, x61], [y60, y61],
[x61, x62], [y61, y62],
[x62, x63], [y62, y63],
[x63, x64], [y63, y64],
[x64, x65], [y64, y65],
[x65, x66], [y65, y66],
[x66, x67], [y66, y67],
[x67, x60], [y67, y60], 'k-', **plot_style)

print(x1)
print(y1)

def main():
a = np.array([x44, y44])
b = np.array([x46, y46])
dis1 = np.linalg.norm(b - a)

c = np.array([x37, y37])
d = np.array([x41, y41])
dis2 = np.linalg.norm(d - c)

e = np.array([x48, y48])
f = np.array([x54, x54])
dis3 = np.linalg.norm(f - e)

plt.xlim(300, 100)
plt.ylim(320, 120)

plt.grid()

0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
kmmn1120
Python素人です。よろしくお願いします。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?