Clean MicroSD card space

15 06 2016

I have 16 GB microsd card use in Windows and Ubuntu. When I want to format this card Windows can read only 70.4 MB, Oh it lost a lot. I think Windows can’t read some Linux files. OK let’s clean it up.

a01

With “DiskPart” software in Windows, This work will run in command line, don’t worry it will show step by step. Click on Start menu (Windows logo) and type “diskpart” then click diskpart program.

a02

The DiskPart dialog box will show up.

a03

Then follow this step by step

  1. list your disk by type “list disk” then enter. it will show all of your disk in your computer.  for example I have 500 GB HDD, 8 GB boot up disk and 16 GB microSD. it will show Disk 0 Disk 1 and Disk 2 my 16 GB microSD located in Disk 2.
  2. Select disk (Disk 2 for me) by type “select disk 2” and enter.
  3. now clean their space by type “clean” then enter.
  4. next create partition by type “create partition primary” then enter.
  5. go to new partition by type “select partition 1” then enter.
  6. set active by type “active” then enter.
  7. format it by type “format fs-ntfs quick” then enter and wait until format finish.
  8.  assign dike for use by type “assign” then enter.
  9. finish. you can exit diskpart by type “exit” and click enter.

the response should be like this image.

a17

Now Windows can see 14.4 GB on microSD disk.

a16





Python: Read Excel file

14 07 2014

read data in excel by python using xlrd plugin
dataxls

import xlrd
xlsName = "data.xls"
book = xlrd.open_workbook(xlsName)
print "The Number of worksheets is ", book.nsheets
print "Worksheet name(s):", book.sheet_names()
sht = len(book.sheet_names())
for i in range(sht):
   sh = book.sheet_by_index(i)
   print "%s have %d rows %d columns"%(sh.name, sh.nrows, sh.ncols)
worksheet = book.sheet_by_index(0)
header_row = 0
headers = [worksheet.cell_value(header_row,i) for i in xrange(worksheet.ncols)]
print headers
def getVal(raw,row,col):
   if raw == xlrd.XL_CELL_EMPTY:
     value = None
   elif raw == xlrd.XL_CELL_TEXT:
     value = worksheet.cell_value(row, col)
   elif raw == xlrd.XL_CELL_NUMBER:
     value = float(worksheet.cell_value(row,col))
   elif raw == xlrd.XL_CELL_DATE:
     value = xlrd.xldate_as_tuple(worksheet.cell_value(row, col), workbook.datemode)
   elif raw == xlrd.XL_CELL_BOOLEAN:
     value = bool(worksheet.cell_value(row, col))
   else:
     value = worksheet.cell_value(row, col)
row_dict_list = []
for row in xrange(header_row+1, worksheet.nrows):
   rowData = [worksheet.cell_value(row,i) for i in xrange(worksheet.ncols) ]
   row_dict_list.append(rowData)

the result show:

The Number of worksheets is 2
Worksheet name(s): [u’Sheet4′, u’Sheet5′]
Sheet4 have 121 rows 6 columns
Sheet5 have 0 rows 0 columns
[u’No.’, u’NAME’, u’DISTANCE (M)’, u’P&L’, u’TRANSACTION’, u’DOWNTME’]





Python: OpenCV: resize image by width

6 07 2014

resize big image by width for example there are 5400×2700 pixels and want to display by 1000 pixel width. try this
import cv2
filename = 'bigimage.jpg'
W = 1000.
oriimg = cv2.imread(filename,cv2.CV_LOAD_IMAGE_COLOR)
height, width, depth = oriimg.shape
imgScale = W/width
newX,newY = oriimg.shape[1]*imgScale, oriimg.shape[0]*imgScale
newimg = cv2.resize(oriimg,(int(newX),int(newY)))
cv2.imshow("Show by CV2",newimg)
cv2.waitKey(0)

if image has width less than 1000 it will be enlarge image.





Python: Install OWSLib package on windows 7 64 bit

21 04 2014

20140421

OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models. There are no binary package for windows but you can use this way to install.

 

step 1:

you need to install easy_install.exe it come with setuptools package. download setuptools link

after install setuptools you will have c:\Python27\Scripts\easy_inistall.exe

 

step 2:

open command prompt (terminal window) [how to open command prompt ]

type this in command prompt window

C:\Users\EnyMap>cd\
C:\>cd Python27\Scripts
C:\Python27\Scripts>easy_install.exe OWSLib

 

when this message show that mean package installed

Finished processing dependencies for OWSLib

C:\Python27\Scripts>

now you can test OWSLib by follow tutorial [Tutorial OWSLib]

enjoy! or leave comment🙂





KMPLAYER: How to disable right panel

18 03 2014

KMPLAYER: How to disable right panel

20140318

KMP player is favor player to play music and movie  in many format. After version 3.7 there are search and advertise panel appear on the right when play the movie. If you want to disable it you can click on the small white arrow at the edge between main and right panel( at the arrow cursor in image) or you can follow this step to set disable right panel every time you open KMP player.

  •  you have to edit hosts file , it located in  “c:/windows/system32/drivers/etc/host”
    Clipboard01
  • to edit hosts file I use Notepad++
    and add
    127.0.0.1 player.kmpmedia.net
    and save hosts file
    this line will prevent the kmplayer to connect to the internet then right panel sidebar will not appear!
    Clipboard02
  • enjoy your movie
    Clipboard15




Pyahon: List data from two lists

11 12 2013

20131211

When we want to display data from 2 lists we can do this.

a = [1,2,3,4,5]

b = [6,7,8,9,0]

if we use zip funcetion

zip(a,b)

the output is [(1,6),(2,7),(3,8),(4,9),(5,0)]

we can display in loop for

for i in zip(a,b):

     pirnt i

the output will show

(1,6)

(2,7)

(3,8)

(4,9)

(5,0)

 





Python: OpenCV: Plot points on image

4 09 2013

Python: OpenCV: Plot points on image

20130904

use cv2 to plot points on image
point symbol like control point symbol

การพล๊อตข้อมูลจุดลงไปบนภาพ โดยกำหนดลักษณะของจุดเป็นแบบรูปจุดควบคุม

code:

import cv2
 if __name__ == '__main__':
 image067="""
    1,2725.816,1578.254
    2,2339.446,1381.908
    3,2263.594,1318.698
    4,2261.619,1222.698
    6,1941.855,1376.561
    7,1941.188,1288.783
    ...
    68,2357.619,1264.970
    """
 imageFile = r'ladybug067.jpg'
 imagePointList = data2List(image067)
 OriImage = cv2.imread(imageFile)

## plot point on image
 for i in imagePointList:
   pid,cx,cy = i
   cv2.circle(OriImage,(int(cx),int(cy)),10,(255,255,255),-11)
   cv2.circle(OriImage,(int(cx),int(cy)),11,(0,0,255),1) # draw circle
   cv2.ellipse(OriImage, (int(cx),int(cy)), (10,10), 0, 0, 90,(0,0,255),-1 )
   cv2.ellipse(OriImage, (int(cx),int(cy)), (10,10), 0, 180, 270,(0,0,255),-1 )
   cv2.circle(OriImage,(int(cx),int(cy)),1,(0,255,0),1) # draw center
   cv2.putText(OriImage,pid,(int(cx)+10,int(cy)-10),cv2.FONT_HERSHEY_COMPLEX_SMALL,1,(255,180,180))
 print 'plot points completed'
 outputfile = 'PlotPoint'+imageFile
 cv2.imwrite(outputfile,OriImage)

รูปร่างของจุดที่ได้

the symbol will like this cp








Follow

Get every new post delivered to your Inbox.