스터디/Processing 2016. 10. 21. 22:35

[Processing] openCV를 활용한 트래킹 영역 설정 및 왜곡 보정


위쪽은 일단 포토샵으로 만든거긴한데 레고패널 위에 양 모서리에 흰색 동그라미 하나씩 두면 웹캠 영상 중에 그 영역 안의 부분만 캡쳐해서 쓰는 코드 작성.

일단 처리 순서는 뭐가 더 효율적인지는 잘 모르겠지만 내가 만든 방법은

1) openCV로 받은 이미지 중 흰색 부분을 다 contour 추출 

2) contour들을 bounding box 씌워주고 중심점 추출 

3) 그 중심점들과 전체화면의 각 모서리들간의 거리를 구해서 4개의 점에서 젤 가까운 상하좌우 obeject를 찾는다

4) 그 4개점을 연결해주는 사각형안에 있는 부분만 Warpperspective 로 다시 픽셀 재배열 하여 우측 타겟사각형 안에 구겨넣음 


이렇게 해두면 나중에 웹캠 위치나 각도 보정도 되고, 프로젝션이랑 카메라인풋이랑 싱크시키기도 좀더 수월해지고, 

아래 판의 크기에 따라서 프로젝션되는 영역 자체도 작고 커지는 scalablity가 생겨서 다른 데모만들떄 좀 유용하지 않을까 기대중


맥에 기본 카메라인 facetime 말고 외부 웹캠으로 불러오게하는 방법

http://www.codingcolor.com/2014/01/21/processing-2-1-webcam-basics/


오브젝트 거리 구하는것도 좀더 정교한 방식도 있다

http://www.pyimagesearch.com/2016/04/04/measuring-distance-between-objects-in-an-image-with-opencv/


WarpPerspecvie 샘플 (여기서는 detection된 contour 네개중에 몇번째거만 오른쪽으로 띄우라는 예제이므로 변형해서 사용)

https://github.com/atduskgreg/opencv-processing#warpperspective-in-progress


Contour간의 위계도 지정하기

http://docs.opencv.org/trunk/d9/d8b/tutorial_py_contours_hierarchy.html


contour 간의 sorting 순서 

http://www.pyimagesearch.com/2015/04/20/sorting-contours-using-python-and-opencv/




스터디/Processing 2016. 10. 21. 22:12

[Processing] OpenCV를 활용한 Shape Detection

급히 정리하는 opencv

프로세싱에서 Import library 해보면  openCV가 두개가 뜬다.


위에 openCV는 좀 예전 버젼이고 http://ubaa.net/shared/processing/opencv/

아래 openCV for processing이 비교적 최근 버젼이며 예제도 더 많다.  (레퍼런스 페이지 http://atduskgreg.github.io/opencv-processing/reference/gab/opencv/OpenCV.html  Github https://github.com/atduskgreg/opencv-processing) 

그리고 이 둘다 openCV for java로 이루어져있기때문에 포함되어있지않은  예제나 설명부분은 java 레퍼런스 페이지에 가면 좀더 응용할여지를 찾아볼수있는듯. 

물론 openCV 오리지널 레퍼런스 페이지로 가게되면 C++기반이긴하지만 원래 어떤 기능들이 더 지원가능한지도 가늠하는데 도움이 되고 있음 (그래도 C++은 몰라서 나에겐 해독이 잘안되는편..)

두가지가 지원 버젼 및 윈도우용 64비트 문제가 뒤엉켜있는데 환경에 맞게 잘 선택해야할듯.

특히 2에서 3로 바뀌면서 setup()에서 캔버스 사이즈를 변수로 받아오는 기능이 없어져서 오로지 픽스된 숫자로만 캔버스 사이즈 기능을 저장할수있게 되었기 떄문에 기존 예제들 중에 플렉서블하게 만들어둔것들은 고정 숫자로 바꿔줘야함. 그래서 지금 테스트는 주로 2로 하는중~



아래 세가지 소스를 조합해서 실시간 비디오로 shape detection + Identification + motion detection까지 되는 데모를 만들었다

지금은 그냥 일반 카메라로 블랙배경 + 흰 물체로만 하고 손은.. 까만 장갑끼고 ㅋㅋㅋ 

요 다음 단계로는 적외선 카메라로 흰색으로 반사된 오브젝트만 트랙킹하는걸로 바꿀거라 손은 사라짐



opencv for processing 예제 중에 find countors + polygon vertex 그려주는 예제 

https://github.com/atduskgreg/opencv-processing/blob/master/examples/FindContours/FindContours.pde


트랙킹된 오브젝트 contour를 둘러싸는 bounding box 만들기 

http://docs.opencv.org/2.4/doc/tutorials/imgproc/shapedescriptors/bounding_rects_circles/bounding_rects_circles.html


Daniel Shiffman의 페이스 디텍션되는 숫자에 boudning box만들어주고 consistent한 ID부여하기 코드

http://shiffman.net/general/2011/04/26/opencv-matching-faces-over-time/


이 다음에는 각 shape들이 사전에 등록된 id와 매칭이 되게 하는 template matching 기능과 결합할 예정 

http://www.prodigyproductionsllc.com/articles/programming/template-matching-with-opencv-and-c/




스터디/Processing 2016. 10. 4. 23:34

[Processing] Computer vision for processing (Daniel Shiffman)

명불허전 다니엘 쉬프만 (http://shiffman.net/) 님의 컴퓨터 비전 기초 강의

유투브 재생목록 클릭 

11.4: Introduction to Computer Vision

11.5: Computer Vision: Color Tracking

11.6: Computer Vision: Motion Detection

11.7: Computer Vision: Blob Detection

11.8: Computer Vision: Improved Blob Detection

11.9: Computer Vision: Blob Tracking with Persistence

11.10: Computer Vision: Adding Lifespan to Blobs


졸업 프로젝트에서 뷰포리아 마커 트랙킹 쓰려했는데 환경도 너무 어둡고 마커위에 프로젝션이 되서 색상 트랙킹이 잘안되서 OpenCV로 갈아탈까 생각중

요 강의 목록에서는 간단하게 컬러트랙킹, 이전프레임과의 픽셀 차이값을 비교한 모션 디텍션, 그리고 Bulb 여러 점들을 디텍션하는 세가지 주제로 이루어져있다. 

뒤로갈수록 슨생님도 헷갈리고 나도 헷갈리고..........

shape detection이랑 bult detection이 혼합된 플로우를 만들어야되는데 과연 내가 할수있는 일인걸까

이거 다음엔 키넥트 강좌인데 일단은 키넥트는 빼기로 했다.

아무튼 또 굿럭



스터디/Processing 2016. 4. 14. 22:48

Openweather API


1. openweathermap API에서 현재 날씨 불러오기


도시 이름으로 불러오기

도시 ID로 불러오기

위치값으로 불러오기
http://api.openweathermap.org/data/2.5/weather?lat=36.321388&lon=127.419724

우편주소로 불러오기
http://api.openweathermap.org/data/2.5/weather?zip=305701,kr

디폴트 모드는 javascript를 위한 JSON이므로 주소 뒤에 xml로 불러오는 부분 추가
&mode=xml

화씨를 섭씨로 바꾸는 부분
&units=metric


대전 현재 날씨


+ 160428  추가
 APIkey 를 별도로 신청해서 기입해야하는 방식으로 바뀜
http://openweathermap.org/appid#get
가입후 무료 API key 신청 후 할당받은 키를 코드 맨 뒤에  &APPID=12345838 이런 식으로 추가해주면 됨 

2. 날씨 예보

오늘 예보 : weather부분을 forecast/daily 로 교체

5일 예보 : weather부분을 forecast 로 교체

3. Parameters:
  • city
    • city.id City ID
    • city.name City name
    • city.coord
      • city.coord.lon City geo location, longitude
      • city.coord.lat City geo location, latitude
    • city.country Country code (GB, JP etc.)
    • city.sun
      • city.sun.rise Sunrise time
      • city.sun.set Sunset time
  • temperature
    • temperature.value Temperature
    • temperature.min Minimum temperature at the moment of calculation. This is deviation from 'temp' that is possible for large cities and megalopolises geographically expanded (use these parameter optionally).
    • temperature.max Maximum temperature at the moment of calculation. This is deviation from 'temp' that is possible for large cities and megalopolises geographically expanded (use these parameter optionally).
    • temperature.unit Unit of measurements. Possilbe valure is Celsius, Kelvin, Fahrenheit.
  • humidity
    • humidity.value Humidity value
    • humidity.unit %
  • pressure
    • pressure.value Pressure value
    • pressure.unit hPa
  • wind
    • wind.speed
    • wind.direction
      • wind.direction.value Wind direction, degrees (meteorological)
      • wind.direction.code Code of the wind direction. Possilbe value is WSW, N, S etc.
      • wind.direction.name Full name of the wind direction.
  • clouds
    • clouds.value Cloudiness
    • clouds.name Name of the cloudiness
  • visibility
    • visibility.value Visibility, meter
  • precipitation
    • precipitation.value Precipitation, mm
    • precipitation.mode Possible values are 'no", name of weather phenomena as 'rain', 'snow'
  • weather
    • weather.number Weather condition id
    • weather.value Weather condition name
    • weather.icon Weather icon id
  • lastupdate
    • lastupdate.value Last time when data was updated


4. 주요 도시

Daegu
1835329




Seoul
1835848

Daejeon
1835235