python 라이브러리 설치:

# pip install numpy

 

 

다차원배열 , 행열, 연산..

선행대수(Linear Alagebra)

  1차원 : axis 0 : vector

  2차원 : axis 1 : matrix ( 행열 )

  3차원 : axis 2 : tensor ( 3차원 이상 )

 

deeplearning 배우려고 pytorch tutorials 찾았더니,, numpy 부터 시작하네..

근데, 이게 뭐야~ ^^;;;

 

https://www.youtube.com/watch?v=LdoJAC26MIc

 

 

mechasolution.net/2017/12/12/%ED%8C%8C%EC%9D%B4%EC%8D%AC-%EC%88%98%EC%B9%98%ED%95%B4%EC%84%9D-2-numpy-zeros-ones-eye-%EC%97%B0%EC%82%B0%EC%9E%90/

 

파이썬 수치해석: 2. Numpy, zeros, ones, eye, 연산자

파이썬 수치해석에서 자주 사용하는 numpy를 활용하여 행렬을 만드는 방법을 살펴보고, 매틀랩에서 사용되는 zeros, ones, eye라는 함수도 파이썬의 numpy를 통해 사용할 수 있다.

mechasolution.net

m.blog.naver.com/PostView.nhn?blogId=lyshyn&logNo=221074812470&proxyReferer=https:%2F%2Fwww.google.com%2F

 

numpy를 이용한 기초 선형대수학

1. 벡터(vector) 1. 벡터(vector) - (벡터) 공간에서의 원소를 표현- 벡터는 각 원소의 데이터 타입이 동일...

blog.naver.com

 

opentutorials.org/module/3653/22995

 

logit, sigmoid, softmax의 관계 - 한 페이지 머신러닝

[logit, sigmoid, softmax의 관계] 이번에는 logit, sigmoid, softmax의 관계에 대해서 알아보겠습니다. 이것들이 서로 다 다른 개념같지만 서로 매우 밀접하게 관련이 있는데요. 그림의 가운데 부분에서 세

opentutorials.org

wikidocs.net/52460

 

위키독스

온라인 책을 제작 공유하는 플랫폼 서비스

wikidocs.net

 

Posted by stekilove
,
Desktop.getDesktop().open(new File("C:\\folder"));

Note: java.awt.Desktop got introduced in JDK 6. is not supported in JDK 5




Runtime.getRuntime().exec("explorer C:\bin");



FileSystemView.getFileSystemView().getHomeDirectory()

Posted by stekilove
,

https://www.learnopencv.com/read-write-and-display-a-video-using-opencv-cpp-python/



위 링크에서 내가 필요한 부분만 찾아서 아래에 기술했는데,

우분투 콘솔서버를 사용중이라서

아래 코드중에서

     cv2.imshow('frame',frame)

부분은 주석처리해서 사용했다.

이렇게하면 웹캠을 실시간 캡쳐해서 avi 로 만들기만하는 코드가된다.



Python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import cv2
import numpy as np
 
# Create a VideoCapture object
cap = cv2.VideoCapture(0)
 
# Check if camera opened successfully
if (cap.isOpened() == False):
  print("Unable to read camera feed")
 
# Default resolutions of the frame are obtained.The default resolutions are system dependent.
# We convert the resolutions from float to integer.
frame_width = int(cap.get(3))
frame_height = int(cap.get(4))
 
# Define the codec and create VideoWriter object.The output is stored in 'outpy.avi' file.
out = cv2.VideoWriter('outpy.avi',cv2.VideoWriter_fourcc('M','J','P','G'), 10, (frame_width,frame_height))
 
while(True):
  ret, frame = cap.read()
 
  if ret == True:
     
    # Write the frame into the file 'output.avi'
    out.write(frame)
 
    # Display the resulting frame   
    cv2.imshow('frame',frame)
 
    # Press Q on keyboard to stop recording
    if cv2.waitKey(1) & 0xFF == ord('q'):
      break
 
  # Break the loop
  else:
    break 
 
# When everything done, release the video capture and video write objects
cap.release()
out.release()
 
# Closes all the frames
cv2.destroyAllWindows()

캠쳐를 실패했을때

웹캠 디바이스를 확인하고 사용가능 모드로 바꿔줘야한다.

ls -alF /dev/video*


결과


crw-r----- 1 root video 81, 0  1월 25 01:15 /dev/video0


뭐 이런경우라면,

root 사용자나 video 사용자만 웹캠을 사용할 수 있다는 말이된다.


sudo chmod 666 /dev/video0


이런식으로 해서 다른 사용자에게 권한을 부여해준다.


Posted by stekilove
,

https://help.ubuntu.com/community/Webcam


위 링크는 우분투에서 웹캠 사용을 어떻게 할지 잘 알려주는 문서이다.

난 우분투에서 콘솔 서버를 사용중이고 

실시간 비데오 스트림을 하는 것이 최종 목표이다.


차례

  1. Choosing a Webcam
  2. Testing Your Webcam Using Cheese
  3. Webcam Software
    1. Configuring Webcam Software
    2. VLC
    3. FFmpeg
    4. MPlayer
    5. MEncoder
    6. Skype
    7. streamer
  4. Identifying Your Webcam
  5. Driver installation
  6. See Also
  7. External Links


Posted by stekilove
,


참고: https://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/



이 문서는 2018년에 작성된 것인데

오래된 우분투 14 버전에 맞춰서 OpenCV 3.0 과 Python 3.4+ 를

설치하려다보니 2015년도에 작성된 것을 참고했다.

번역은 현재에 맞춰서 불필료한 내용은 제거했고,

순전히 설치에만 필요한 내용만 남기기로 했다.


OpenCV 3.0 과 Python 3.4+ 를 Ubuntu 에 설치하기

ubuntu_cv3py3_facedetection

오래된 우분투 14 서버 버전에 설치했다.

버전이 낮다보니 웹에서 찾아서 이것 저것 해보다가 그나마 문제 없이 잘 설치된 이 문서를 옮기기로 했다.

이 문서에 따르면,  일단 제목처럼 OpenCV 3.0 , Python 3.4+ 설치에 집중하고 CMake는 따로 올렸단다. 관심 있으시면 찾아 보시길..

OpenCV 3.0 와 Python 3.4+ 를  Ubuntu 에 어떻게 설치할까

UPDATE: 문서 만든지가 2-3년전인 것 같은데 아직도 Ubuntu 14.04.에서  완벽하게 작동한다. 하지만  Ubuntu 16.04 에서 OpenCV 3.1 과 Python 3.5+ 를 설치하고자 한다면 아래 링크를 확인하세요.

https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/


 OpenCV 3.0 and Python 2.7+ on Ubuntu, 문서는 여진히 파이썬 2.7 사용자에게는 유용하다..

2015년에 작성된 문서라서 

Step 1: 필수 구성요소 설치

기존 패키지 업그레이드:

OpenCV 3.0 컴파일을 위한 개발자툴 설치:

디스크에서 다양한 이미지 포멧을 읽기 위한 라이브러리 설치:

디스크에서 다양한 비디오 포멧을 읽기 위한 라이브러리 설치:

OpenCV’s GUI 특성을 사용할 수 있는 GTK 설치:

매트릭스 처리와 같은 OpenCV에서 사용하는 함수 최적화 패키지 설치:

Step 2: Python 설정 (Part 1)

파이썬3 용 설치 매니저  pip 를 받자:

기억하세요, pip 설치시에  python3 를 명시해야 한다네요.. 안그러면 파이썬 2.7로 설치된데요.

파이썬 개발을 위해서는 가상환경을 사용해야합니다.

 virtualenv 와 virtualenvwrapper 을 이용해서 완전히 독립된 파이썬 개발 환경을 가질 수 있습니다. 프로젝트마다 완전히 별도의 환경을 얻을 수도 있습니다.

 pip3 을 사용해서,  virtualenv  와virtualenvwrapper 를 설치합니다:

다시 말하지만, pip3  를 사용해야합니다. pip 가 아니에요. —Python 3.4.를 이용해서 설치 할테니까요.

이제 우리는 ~/.bashrc  파일을 업데이트합니다. (파일아래붙여요):

파이썬3 실행파일이 우분투 시스템의 어디에 있는지  VIRTUALENVWRAPPER_PYTHON  에 지정합니다.

터미널에 새로 들어 온 것 처럼 ~/.bashrc 를 다시 불러옵니다:

마지막으로, cv 가상환경을 만들어서 OpenCV 3.0 and Python 3.4 개발 비전을 제공합니다:

Step 2: Python 설정 (Part 2)

 Python 설정의 반은 왔네요.. 하지만,  파이썬 3.4+ 바인딩으로 OpenCV 3.0 을 컴파일 위한 Python 3.4+ headers 와 development 파일 설치:

OpenCV 는 NumPy arrays로 이미지를 표현하는데, 그러기 위해서는 NumPy 을  cv 가상환경에 에 설치해야 합니다:

만약에 아래와 같이  pip의 .cache  directory에 대한 권한 문제가 발생하면:

Figure 1: If you get a "Permission Denied" error, no worries -- that's an easy fix!

Figure 1: If you get a “Permission Denied” error, no worries — that’s an easy fix!

그냥 간단히 cache directory 를 지우고  NumPy 를 다시 설치하세요:

그러면,  NumPy를 잘 설치 할 수 있습니다:

Figure 2: Deleting the .cache/pip directory and re-running pip install numpy will take care of the problem.

Figure 2: Deleting the .cache/pip directory and re-running pip install numpy will take care of the problem.

Step 3: Python 3.4+ bindings 으로 OpenCV 3.0 을 만들고 설치한다

지금 드디어 설정이 다 끝났습니다 !! Let’s GifHub에서 OpenCV 를 pull 해서 3.0.0  version을 checkout 합시다:

Update (3 January 2016):  3.0.0  version 을 어떤 버젼으로든 바꿀 수 있습니다. (지금은, 3.1.0 ).  OpenCV.org 에서 최신정보를 확인하세요.

 opencv_contrib repo 도 가져옵니다. ( opencv_contrib 가 왜 필요한지 알려면,  previous OpenCV 3.0 Ubuntu install post):

같은 버젼의 opencv_contrib  를 가져옵니다. 그렇게 하지 않으면 오류가 납니다..

빌드할 시간입니다:

Update (3 January 2016): OpenCV 3.1.0 설치를 위해서는,  -DINSTALL_C_EXAMPLES=OFF  옵션이 필요합니다. (rather than ON ).  OpenCV v3.1.0 CMake build script 에 오류가 있습니다. 그것은 스위치온으로 남겨두면 오류가 납니다. 스위치오프로 한 번 해놓으면, CMake 는 문제없이 동작합니다.

CMake output을 몇 초간 보세요:

Figure 3: It's a good idea to inspect the output of CMake to ensure the proper Python 3 interpreter, libraries, etc. have been picked up.

Figure 3: It’s a good idea to inspect the output of CMake to ensure the proper Python 3 interpreter, libraries, etc. have been picked up.

Notice how CMake has been able to pick up our Python 3 interpreter! This indicates that OpenCV 3.0 will be compiled with our Python 3.4+ bindings.

Speaking of compiling, let’s go ahead and kickoff the OpenCV compile process:

컴파일 시간을 빠르게 하기 위해서, 컴퓨터에 따라서 번호 4를 바꿀 수도 있습니다.

OpenCV 3.0 컴파일에 문제가 없다면, 설치를 하세요:

Step 4: Sym-link OpenCV 3.0

여기까지 설치가 되었다면, OpenCV 3.0 은 해당 경로에 있답니다. /usr/local/lib/python3.4/site-packages/

Figure 4: The Python 3.4+ OpenCV 3.0 bindings are now installed in /usr/local/lib/python3.4/site-packages/

Figure 4: The Python 3.4+ OpenCV 3.0 bindings are now installed in /usr/local/lib/python3.4/site-packages/

여기, OpenCV bindings 은 이 이름으로 존재합니다. cv2.cpython-34m.so

몇 초동안  실제 저 이름으로 존재하는지 확인하세요!

어째꺼나, cv  가상 환경에서OpenCV 3.0 을 사용하기 위해서  , 먼저  cv  환경에서 sym-link OpenCV 를 site-packages  경로에 연결시킵니다.:

주목하세요,  cv2.cpython-34m.so  를 cv2.so  이름으로 링크합니다— 이렇게 해야지, Python이  cv2 이름을 이용해서 OpenCV 바인딩을 import 할 수 있습니다..

그래서, 지금 cv  가상 환경에서 site-packages  경로를 조회하면, OpenCV 3.0 bindings (cv2.so  file)을 볼 수 있습니다:

Figure 5: In order to access the OpenCV 3.0 bindings from our Python 3.4+ interpreter, we need to sym-link the cv2.so file into our site-packages directory.

Figure 5: In order to access the OpenCV 3.0 bindings from our Python 3.4+ interpreter, we need to sym-link the cv2.so file into our site-packages directory.

다시 말하지만, 이것은 매우 중요한 단계입니다,  cv2.so  file 이 가상환경에 있는지 반드시 확인해야합니다. 그렇지 않으면, OpenCV in your Python scripts를 가져올(import) 수 없습니다 !

Step 5:  OpenCV 3.0 테스트와 Python 3.4+ 설치

훌륭합니다! 당신은 성공적으로 Python 3.4+ bindings 과 OpenCV 3.0 (그리고 가상환경) 을 당신의 시스템에 설치했습니다!

하지만, 샴페인과 맥주를 마시기전에, 작동되는 설치를 했는지 확인합시다. 먼저,  cv  가상환경에 있는지 확인하고, 다음에  Python 3 에서 cv2 import를 시도하세요:

여기 예제가 있습니다:

Figure 6: OpenCV 3.0 with Python 3.4+ bindings has been successfully installed on the Ubuntu system!

Figure 6: OpenCV 3.0 with Python 3.4+ bindings has been successfully installed on the Ubuntu system!

당신이 보는데로, OpenCV 3.0 with Python 3.4+ bindings 우분투 시스템에 성공적으로 설치가 되었습니다!

요약

In this tutorial I have demonstrated how to install OpenCV 3.0 with Python 3.4+ bindings on your Ubuntu system. This article is very similar to our previous tutorial on installing OpenCV 3.0 and Python 2.7 on Ubuntu, but takes advantage of OpenCV 3.0’s new Python 3+ support, ensuring that we can use the Python 3 interpreter in our work.

While having Python 3.4+ support is really awesome and is certainly the future of the Python programming language, I would also advise you to take special care when considering migrating from Python 2.7 to Python 3.4. For many scientific developers, the move from Python 2.7 to 3.4 has been a slow, arduous one. While the big Python packages such as NumPy, SciPy, and scikit-learn have made the switch, there are still other smaller libraries that are dependent on Python 2.7. That said, if you’re a scientific developer working in computer vision, machine learning, or data science, you’ll want to be careful when moving to Python 3.4 as you could easily pigeonhole your research.

Over the coming weeks the OpenCV 3.0 install-fest will continue, so if you would like to receive email updates when new install tutorials are released (such as installing OpenCV 3.0 with Homebrew, installing OpenCV 3.0 on the Raspberry Pi, and more), please enter your email address in the form below.


Posted by stekilove
,

https://help.ubuntu.com/community/WifiDocs/Scan_for_Wireless_Network




Find Network Interface Card


ls /sys/class/net


cd /sys/class/net/[wifi interface]/wireless/

Release network connections

sudo ip link set dev [wifi interface] down sudo dhclient -r [wifi interface] sudo ip link set dev [wifi interface] up

Scan

sudo iwlist [wifi interface] scan


wlan0 Scan completed :
Cell 01 - Address: 00:04:E2:D0:D1:96
ESSID:"SMC"
Mode:Master
Channel:6
Frequency:2.437 GHz
Quality=78/100 Signal level=-56 dBm Noise level=-127 dBm
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s
Extra:tsf=00000039cdb32ac3

Setup Network Interface Card


sudo iwconfig [wifi interface] ap [whatever you found for the MAC address]
sudo iwconfig [wifi interface] essid [whatever you found for essid]
sudo iwconfig [wifi interface] freq [whatever you found for frequency]G

Note the "G" after the frequency, to denote "GHz".

Acuire Network Address

sudo dhclient [wifi interface]


Compatible Chipsets

lspci

\


Posted by stekilove
,

private  int executeCallableStatement(final String aSql, final Integer fetchSize, QueryListener queryListener) throws SQLException {


if(isNotConnected()){

try{

queryListener.onError("DB연결을 먼저하세요!!");

}

finally{

queryListener.onFinished();

}

return 0;

}

final String sql = trimSqlErrorString(aSql);

int rownums=0;

ResultSet rset = null;

CallableStatement stmt = null;//ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);

try{

stmt = connMgr.prepareCall(sql);

stmt.execute();

queryListener.onEachQueryExecuting(stmt);

if(stmt.getMoreResults()){

rset = stmt.getResultSet();

rownums = queryListener.onEachResultSet(sql, rset, fetchSize);

}

else {

rownums = stmt.getUpdateCount();

queryListener.onUpdatedCount(rownums, sql);

}

}

finally{

connMgr.close(rset, stmt);

queryListener.onEachQueryClosed();

}

return rownums;

}

private String trimSqlErrorString(String aSql) {

//.replaceAll("--[^\n]+\n", "").replaceAll("/\\*[^/]+\\*/", "").replaceAll("\\?","'1'").trim();

return MyStringUtil.trim(aSql).replaceAll("/\\*\\s+", "/*");

}

Posted by stekilove
,

oracle tune

computer programming 2018. 1. 20. 01:27

https://oracle-base.com/articles/8i/explain-plan-usage


https://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements006.htm#SQLRF51098


https://oracle-base.com/articles/9i/dbms_xplan



https://oracle-base.com/articles/11g/real-time-sql-monitoring-11gr1





select /*+MONITOR*/ from dual;


Posted by stekilove
,
EXPLAIN PLAN
   SET STATEMENT_ID = 'st1'
   INTO my_plan_table
 FOR
SELECT last_name FROM employees;
SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());

SELECT PLAN_TABLE_OUTPUT 
  FROM TABLE(DBMS_XPLAN.DISPLAY('MY_PLAN_TABLE', 'st1','TYPICAL'));


https://docs.oracle.com/cd/B28359_01/server.111/b28274/ex_plan.htm#i16938


http://www.oracle.com/technetwork/database/bi-datawarehousing/twp-explain-the-explain-plan-052011-393674.pdf




https://blogs.oracle.com/sql/how-to-create-an-execution-plan


Posted by stekilove
,
Objective-C 계열의 cheet나 요약본 그리고 투터리얼을 구해서 공부하기 시작했다.

맥을 구매해서 xcode상에서 iphone 프로그래밍 하겠다는 것은 나중으로 미루기로 했다.
어차피 iphone상에 내가 만들어 보고 싶은 것들은 화면처리보다는 내용처리쪽이 더 많다고 생각되기 때문이다. (HelloWorld를 찍으려고 맥을 구매한다는 것은 왠지 돈이 아깝다)

MVC 패턴을 기반으로 보면,
    M:Model ==> Data구조 (sqlite 사용)
    V:View ==> 화면처리 (iphone에서 제공하는 api 또는 OpenGL, etc)
    C:Control ==> 각 화면에서 받은 명령에 대해서 모델을 기반으로 처리
M,C와 같은 경우,
GNUStep에서 구현해서 iPhone으로 포팅하면 되고,
View단은 iPhone전용 API를 고려해서 만들면 된다.

돈도 없고, 취미생활할 여유가 없는 상황에서
무리하게 환경이 갖춰지기만을 기다리려니 내 자신이 한심해서
가난했던 젊은 시절을 생각하며, 돌파구를 찾기로 했다.

그래서 시작한 것이,
    1. C++ 과 Objective-C를 비교한 예제를 기반으로 코드에 익숙해지기
    2. Objecitve-C 문법 투터리얼 따라하기
    3. Java Collection과 유사한 Objective-C API 사용방법 익히기
    4. cocoa pattern 책을 참고해서 gnustep에서 포팅을 염두에 두고 개발한다.
        GNUstep의 Gorm은 iPhone의 Insterface Builder와 거의 흡사하다.
등이다.

위 스터디가 끝나면,
    5. iphone용 앱스토어에 올라와 있는 application과 동일 한 것들을 만들어 본다.
        물론, 하드웨어적으로 다른것은 제외하거나 우회하도록 한다.
    6. 이런 일련의 스터디를 하면서
        vmware workstation을 이용해서 os x및 xocde를 설치하고 포팅작업을 해 본다.

그리고,
    7. 나만의 어플을 개발해 본다.
    8. 가상윈도우에서 만들어서 탈옥(hacking)된 iPod에 올려서 테스트 한다. :)
       문제는 아직 iPod이 없다. ㅠ_ㅠ

그리고, ㅠ_ㅠ
    9. 맥스토어에 올리기위해서는 맥을 사야하고
   10. 게다가, 매 년 활동비를 지급해야 한다. :(
   11. 맥스토어 올리는 것도 그닥 쉽지 않단다.


LINK:
http://en.wikipedia.org/wiki/GNUstep
http://www.gnustep.org
http://gnustep.made-it.com/GSPT/xml/Tutorial_en.html
http://pierre.chachatelier.fr/programmation/fichiers/cpp-objc-en.pdf
http://www.amazon.com/Cocoa-Design-Patterns-Erik-Buck/dp/0321535022
http://developer.apple.com/iphone/
http://blog.naver.com/stekilove/50081536864  - ubuntu에 GNUstep 설치 ( + sqlite )
http://steki.springnote.com/pages/5167295 - ubuntu에 OpenGL설치

Posted by stekilove
,