บทความ

กำลังแสดงโพสต์จาก สิงหาคม, 2018

python Physics Engine

http://pymunk.org/

google text to speech

ใน python ใช้อันนี้ https://gtts.readthedocs.io/en/latest/ (ต้องต่อ net) การติดตั้ง.. python3 -m pip install gTTS การทดสอบ.. gtts-cli 'ชลิตา' --output testVoice.mp3 --lang th การใช้ใน python https://gtts.readthedocs.io/en/latest/module.html#module-gtts.tts

สร้าง android app ด้วย framework

-flutter ใช้ภาษา dard ให้ลืม ui เดิมไปเลย เพราะมันมี widget ของมัน -react native ใช้ js และยังติดต่อกับ native ui ได้ ทั้งคู่ เขียนทีเดียว built ออกมาเป็นได้ทั้ง android และ iOS

maya 2018 การ reset maya setting

https://knowledge.autodesk.com/support/maya/troubleshooting/caas/sfdcarticles/sfdcarticles/Reset-Maya-to-Default.html?_ga=2.269179057.1114650682.1534849367-1275139.1534241839

maya 2018 : การเปิดโหลด คลิกแล้วลากเพื่อสร้างวัตถุ (2-step to create object)

รูปภาพ
โหมดนี้มีชื่อว่า Interactive Creation ถ้าเจอปัญหา คลิกแล้ว วัตถุมันถูกสร้างเลย ลากขยายไม่ได้ ให้แก้ด้วยการเปิดโหมดนี้

python3 : this

ใน python ไม่มี this keyword ในการที่จะอ้างอิง member class จากใน class method เราต้องนิยาม argument ตัวแรกของ class method ด้วย self เพื่อให้สามารถใช้ self.xxx อ้างอิงไปยัง member class อื่นๆได้ ซึ่งมันจะเป็น hidden argument อัตโนมัติ ซึ่งจะไม่ถูกมองว่าเป็น argument เมื่อข้างนอกมาเรียกใช้ เช่น class Man( ):     x = 10     def walk(self, ...) :         print (self.x)

python3 : แสดง array, matrix แบบสวยๆ ด้วย DataFrame (pandas)

https://stackoverflow.com/questions/13214809/pretty-print-2d-python-list

Python3: openCV การ resize image แบบ รักษา aspect

https://stackoverflow.com/questions/44650888/resize-an-image-without-distortion-opencv

python3: openCV การวาด สี่เหลี่ยมลงในภาพ

cv.rectangle(ไฟล์ภาพที่ต้องการแก้ไข,(x_start, y_start),(x_stop, y_stop),(สี R,G,B), ความหนาของเส้นเช่น 1)

python3: matplotlib การใส่เลขบอกตำแหน่งเอาเองในกราฟ

plt.title('Result in JET'), plt.xticks([]),# ใส่เป็น list ว่างๆคือ กำหนดไม่ให้แสดงขีดบอกพิกัด plt.yticks([]) #ถ้าต้องการเลขบอกพิกัดเอง ดูใน ref นี้ # https://matplotlib.org/api/_as_gen/matplotlib.pyplot.xticks.html

TensorFlow: การแสดงภาพ จากฐานข้อมูล mnist

import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data DATA_DIR = './tmp/data' data = input_data.read_data_sets( DATA_DIR , one_hot = True ) batch_xs1, batch_ys1 = data.train.next_batch( MINIBATCH_SIZE ) import matplotlib.pyplot as plt first_array = batch_xs1[ 0 ] # ได้ shape (784,) ต้อง reshape เป็น 28,28 plt.gray() # ให้แสดงเป็นภาพ gray scale plt.imshow(first_array.reshape([ 28 , 28 ])) #Actually displaying the plot if you are not in interactive mode plt.show() ที่มา: https://stackoverflow.com/questions/38308378/tensorflow-show-image-from-mnist-dataset

numpy : สุ่มตัวเลข integer ในขอบเขตจำกัด ด้วย np.random.binomial

รูปภาพ
อธิบายโค้ด.. x = np.random.binomial(n, p, size=None) n กำหนดเป็น 7 หมายถึง ค่าที่สุ่มจะเป็นได้ตั้งแต่ 0 ถึง 7 p กำหนดเป็น .5 หมายถึง แต่ละค่ามีโอกาศเกิด 50% size คือ ความถี่(ค่าแกน y) ของทุกตัวเลขรวมกันแล้วจะได้เท่ากับค่านี้ (*size เป็น option **ถ้ากำหนดมากกว่า 1 จะได้ผลลัพธ์ออกมาเป็น list) อ่านเพิ่มเติมในเรื่อง Binomial Distribution https://sites.google.com/site/mystatistics01/chapter1/probability-distribution ref: https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.random.binomial.html