레이블이 Android인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Android인 게시물을 표시합니다. 모든 게시물 표시

2022년 12월 8일 목요일

ffmpeg 명령어 모음

ffmpeg 명령어 모음

* ffmpeg 프레임 추출
$ ffmpeg -ss 00:00:0 -i input.mp4 -r 10 -f image2 input-%d.png

* ffmpeg resizing
$ ffmpeg -i input.mp4 -vf scale=4032:756 -preset slow -crf 18 -strict -2 output.mp4

2022년 6월 15일 수요일

안드로이드 화면 캡쳐하기

프로그래밍으로 화면 캡쳐하기.
아래 명령어는 system app으로 등록되어야 가능합니다.

2022년 5월 24일 화요일

화면 가로/세로 모드 조정하기

1. 가로 모드 고정
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

2. 세로 모드 고정
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

2022년 4월 21일 목요일

Windows에서 webcam을 이용해서 RTSC 서버 구축과 영상 스트리밍하기

1. rtsc 서버 설치하기
아래 링크에서 rtsc simple 서버 프로그램을 다운로드 받아서 압축을 풀고 rtsp-simple-server.exe 실행

2. ffmpeg 을 이용해서 웹캠 화면을 rtsc 서버로 보내기

https://www.gyan.dev/ffmpeg/builds/ 의 release builds section에서 ffmpeg-release-full.7z 를 다운로드 받아서 압축을 푼다.

ffmpeg/bin/ 를 시스템 환경 변수 PATH에 추가.

cmd 프로그램을 실행.

아래 명령어 실행.

웹캠과 마이크 장치이름을 알기 위해서 ffmpeg -list_devices true -f dshow -i dummy 실행.

아래 명령어로 rtsp 스트리밍 수행.

ffmpeg -f dshow -i video="HD Webcam":audio="마이크(Realtek(R) Audio)" -profile:v high -pix_fmt yuv420p -level:v 4.1 -preset ultrafast -tune zerolatency -vcodec libx264 -r 10 -b:v 512k -s 640x360 -acodec aac -ac 2 -ab 32k -ar 44100 -f rtsp -rtsp_transport tcp rtsp://192.168.1.107:8554/test

Edge나 Chrome의 주소창에 rtsp://192.168.1.107:8554/test 실행하면 컴퓨터에 설치되어 있는 미디어 플레이어에서 실행.

3. ffmpeg 명령어

웹캠영상을 파일로 저장할 때

ffmpeg -f dshow -i video="HD Webcam" -r 20 -t 10 camera.mp4

ffplay로 rtsp 스트리밍 보기

ffplay -fflags nobuffer -flags low_delay rtsp://192.168.1.107:8554/test

4. Reference

2022년 1월 21일 금요일

How to kill Android process

1. Android process 죽이는 방법 1

2. Android process 죽이는 방법 2

2022년 1월 20일 목요일

How to generate .jks file with .pk8 and .pem

$ openssl pkcs8 -inform DER -nocrypt -in platform.pk8 -out platform.pem
$ openssl pkcs12 -export -in platform.x509.pem -inkey platform.pem -out platform.p12 -password pass:android -name platform
$ keytool -importkeystore -deststorepass android -destkeystore platform.jks -srcstoretype PKCS12 -srcstorepass android -srckeystore platform.p12

ValueAnimator 를 이용한 애니메이션 만들기

sequence images 를 사용해서 애니메이션을 표현해야 할 때가 있습니다.
기존에는 AnimationDrawable을 사용해서 애니메이션을 만들었는데 사용하기 쉬운 반면
이미지가 커지면 로딩하는데 시간이 오래 걸리는 단점이 있습니다.
고민 하던 중에 ValueAnimator를 이용해서도 애니메이션을 만들 수 있다는 것을 알았고
이것은 이미지 개수나 사이즈에 상관없이 바로 수행이 되는 장점이 있습니다.

1. ValueAnimator valueAnimator = ValueAnimator.ofInt(valueStart, valueEnd).setDuration(duration);
ValueAnimator는 정해진 duration동안 onAnimationUpdate()를 호출하는데 parameter로 valueStart 부터 valueEnd 사이의 값을 넘겨줍니다.

2. onAnimationUpdate() 내에서 value값에 해당되는 imageview의 리소스를 교체해 줍니다.

3. 예제는 1초 동안 0~99의 값을 onAnimationUpdate()를 통해서 넘겨줍니다.
100개의 이미지가 있고 이것을 1초동안 play하기를 원한다면 이미지들을 배열로 만들어서 해당 value에 맞는 리소스를 교체해 주면 됩니다.

Android adb 명령어

1. screen capture
ex) adb shell screencap -p /sdcard/screen.png

2. 특정 기기 선택
ex) adb -s devicename shell screencap -p /sdcard/screen.png

3. broadcast
adb shell am broadcast -a packagename --ei key value --es key value
ex) adb shell am broadcast -a com.android.test
ex) adb shell am broadcast -a com.android.test --ei event 1 --es name "john snow"

4. 화면 이동
ex) adb shell am start -a android.settings.SETTINGS
ex) adb shell am start -a android.settings.BLUETOOTH_SETTINGS
ex) adb shell am start -n com.android.car.carlauncher/.AppGridActivity

5. display 선택
adb shell am start -a activity --display number
ex) adb shell am start -a android.settings.SETTINGS --display 0

6. app 삭제
ex) adb shell pm uninstall --user 0 com.android.test

7. key event 전달
ex) adb shell input keyevent 4

[Reference]
https://developer.android.com/studio/command-line/adb

2022년 1월 19일 수요일

Android Timer 관련 정리

1. 일정 시간마다 작업하기를 원할 때
Timer와 TimerTask를 이용한 반복 작업 구현.
아래 예제는 15초 동안 5초마다 한번 씩 작업하는 예제
2. 일정 시간마다 작업하기를 원할 때
CountDownTimer를 이용한 반복 작업 구현.
아래 예제는 10초 동안 0.5초마다 한번 씩 작업하는 예제
3. 일정 시간 후에 한 번 원하는 작업을 하고 싶을 때
아래 예제는 1초 후에 한번 작업하는 예제

2020년 8월 17일 월요일

Drawerlayout drag 영역 변경 하기

DrawerLayout 은 drag 할 수 있는 왼쪽/오른쪽 가장자리 영역이 20dp로 고정되어 있습니다.

이 영역을 변경할 수 있는 api가 공식적으로는 없는데 아래와 같은 방법으로 하면 변경할 수 있습니다.

아래 코드의 edge 의 값을 변경 하면 됩니다.

int edge = 30;


private void setDrawerLayoutMargin() {
    java.lang.reflect.Field leftDragger = null;
    java.lang.reflect.Field rightDragger = null;
    try {
        leftDragger = mDrawerLayout.getClass().getDeclaredField("mLeftDragger");
        rightDragger = mDrawerLayout.getClass().getDeclaredField("mRightDragger");
    } catch (NoSuchFieldException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }

    leftDragger.setAccessible(true);
    rightDragger.setAccessible(true);
    ViewDragHelper leftDraggerObj = null;
    ViewDragHelper rightDraggerObj = null;
    try {
        leftDraggerObj = (ViewDragHelper) leftDragger.get(mDrawerLayout);
        rightDraggerObj = (ViewDragHelper) rightDragger.get(mDrawerLayout);
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    java.lang.reflect.Field leftEdgeSize = null;
    java.lang.reflect.Field rightEdgeSize = null;
    try {
        leftEdgeSize = leftDraggerObj.getClass().getDeclaredField("mEdgeSize");
        rightEdgeSize = rightDraggerObj.getClass().getDeclaredField("mEdgeSize");
    } catch (NoSuchFieldException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    leftEdgeSize.setAccessible(true);
    rightEdgeSize.setAccessible(true);
    int edge = 30;
    try {
        leftEdgeSize.setInt(leftDraggerObj, edge * 1);
        rightEdgeSize.setInt(rightDraggerObj, edge * 1);
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

2017년 2월 5일 일요일

NightLight Privacy Policy

nightlight Privacy Policy


This privacy policy has been compiled to better serve those who are concerned with how their 'Personally Identifiable Information' (PII) is being used online. PII, as described in US privacy law and information security, is information that can be used on its own or with other information to identify, contact, or locate a single person, or to identify an individual in context. Please read our privacy policy carefully to get a clear understanding of how we collect, use, protect or otherwise handle your Personally Identifiable Information in accordance with our website.

What personal information do we collect from the people that visit our blog, website or app?

We do not collect information from visitors of our site.
or other details to help you with your experience.

When do we collect information?

We collect information from you when you or enter information on our site.


How do we use your information?

We may use the information we collect from you when you register, make a purchase, sign up for our newsletter, respond to a survey or marketing communication, surf the website, or use certain other site features in the following ways:


How do we protect your information?

We do not use vulnerability scanning and/or scanning to PCI standards.
We only provide articles and information. We never ask for credit card numbers.
We do not use Malware Scanning.

We do not use an SSL certificate
      • We only provide articles and information. We never ask for personal or private information like names, email addresses, or credit card numbers.

Do we use 'cookies'?

We do not use cookies for tracking purposes

You can choose to have your computer warn you each time a cookie is being sent, or you can choose to turn off all cookies. You do this through your browser settings. Since browser is a little different, look at your browser's Help Menu to learn the correct way to modify your cookies.

If you turn cookies off, some features will be disabled. that make your site experience more efficient and may not function properly.

However, you will still be able to place orders .


Third-party disclosure

We do not sell, trade, or otherwise transfer to outside parties your Personally Identifiable Information.

Third-party links

We do not include or offer third-party products or services on our website.

Google

Google's advertising requirements can be summed up by Google's Advertising Principles. They are put in place to provide a positive experience for users. https://support.google.com/adwordspolicy/answer/1316548?hl=en 

We use Google AdSense Advertising on our website.

Google, as a third-party vendor, uses cookies to serve ads on our site. Google's use of the DART cookie enables it to serve ads to our users based on previous visits to our site and other sites on the Internet. Users may opt-out of the use of the DART cookie by visiting the Google Ad and Content Network privacy policy.

We have implemented the following:
      • Remarketing with Google AdSense

We, along with third-party vendors such as Google use first-party cookies (such as the Google Analytics cookies) and third-party cookies (such as the DoubleClick cookie) or other third-party identifiers together to compile data regarding user interactions with ad impressions and other ad service functions as they relate to our website.

Opting out:
Users can set preferences for how Google advertises to you using the Google Ad Settings page. Alternatively, you can opt out by visiting the Network Advertising Initiative Opt Out page or by using the Google Analytics Opt Out Browser add on.

California Online Privacy Protection Act

CalOPPA is the first state law in the nation to require commercial websites and online services to post a privacy policy. The law's reach stretches well beyond California to require any person or company in the United States (and conceivably the world) that operates websites collecting Personally Identifiable Information from California consumers to post a conspicuous privacy policy on its website stating exactly the information being collected and those individuals or companies with whom it is being shared. - See more at: http://consumercal.org/california-online-privacy-protection-act-caloppa/#sthash.0FdRbT51.dpuf

According to CalOPPA, we agree to the following:
Users can visit our site anonymously.
Once this privacy policy is created, we will add a link to it on our home page or as a minimum, on the first significant page after entering our website.
Our Privacy Policy link includes the word 'Privacy' and can easily be found on the page specified above.

You will be notified of any Privacy Policy changes:
      • On our Privacy Policy Page
Can change your personal information:
      • By emailing us

How does our site handle Do Not Track signals?
We honor Do Not Track signals and Do Not Track, plant cookies, or use advertising when a Do Not Track (DNT) browser mechanism is in place.

Does our site allow third-party behavioral tracking?
It's also important to note that we do not allow third-party behavioral tracking

COPPA (Children Online Privacy Protection Act)

When it comes to the collection of personal information from children under the age of 13 years old, the Children's Online Privacy Protection Act (COPPA) puts parents in control. The Federal Trade Commission, United States' consumer protection agency, enforces the COPPA Rule, which spells out what operators of websites and online services must do to protect children's privacy and safety online.

We do not specifically market to children under the age of 13 years old.

Fair Information Practices

The Fair Information Practices Principles form the backbone of privacy law in the United States and the concepts they include have played a significant role in the development of data protection laws around the globe. Understanding the Fair Information Practice Principles and how they should be implemented is critical to comply with the various privacy laws that protect personal information.

In order to be in line with Fair Information Practices we will take the following responsive action, should a data breach occur:
We will notify you via email
      • Other

We also agree to the Individual Redress Principle which requires that individuals have the right to legally pursue enforceable rights against data collectors and processors who fail to adhere to the law. This principle requires not only that individuals have enforceable rights against data users, but also that individuals have recourse to courts or government agencies to investigate and/or prosecute non-compliance by data processors.

CAN SPAM Act

The CAN-SPAM Act is a law that sets the rules for commercial email, establishes requirements for commercial messages, gives recipients the right to have emails stopped from being sent to them, and spells out tough penalties for violations.

We collect your email address in order to:

To be in accordance with CANSPAM, we agree to the following:

If at any time you would like to unsubscribe from receiving future emails, you can email us at
and we will promptly remove you from ALL correspondence.

Contacting Us

If there are any questions regarding this privacy policy, you may contact us using the information below.

NightLight
Ilsandong-gu
Goyang-si, Gyeonggi-do 10449
South Korea
leslie96@gmail.com


Last Edited on 2017-02-05

2016년 3월 7일 월요일

[Android] 소스코드 깔끔하게 정리하기

Android 원본 소스 코드는 깔끔하게 정리가 돼 있어서 알아보기 쉽습니다.
여기에 수정을 하면 사람마다 제각각 스타일이 있어서 어떤 사람은 스페이스로 들여쓰기를 하고
어떤 사람은 탭으로 들여쓰기를 합니다. 괄호를 쓰는 스타일도 제각각이죠.
Eclipse로 코드를 볼 때는 어느정도 정렬을 해서 보여주기 때문에 그나마 보기가 괜찮지만,
텍스트 에디터로 보면 정말 가관이죠. 소스 가독성이 뚝 떨어집니다.
저처럼 이것에 민감한 분들을 위해 쉽게 해결 할 수 있는 방법을 알려드립니다.

1. Formatter 화일 다운로드
2. Eclipse > Window > Preferences > Jave > Code Style > Formatter > Import
3. 소스 코드 작성 후에 Ctrl+Shift+F 를 눌러주기만 하면 예쁘게 정렬이 됩니다.
4. 좀 더 자세히 알고 싶으면 Code Style Rules를 참고하시기 바랍니다.

2015년 12월 27일 일요일

GPS Logger 사용방법(Using GPS Logger)

GPS Logger 사용방법(Using GPS Logger)

1. 앱을 실행하고, 디지털 카메라의 시간을 핸드폰의 시간과 맞춘다.
   Adjust the same time between the digital camera and smartphone.


2. 하단의 "기록" 버튼을 누르고, "GPS와 연결되었습니다." 라는 메시지가 나올때 까지 잠시 기다린다. 실외에서 실제 GPS 신호를 받는것이 좀더 정확한 위치 측정이 됩니다.
   Press the RECORD button. You can see "Connected with GPS" after a while.


3. 룰루라라~~ 사진을 열심히 찍는다.
   Take pictures with your digital camera.

4. 디지털 카메라의 메모리 카드와 핸드폰을 연결한다. 핸드폰으로 그냥 복사를 하게 되면 화일 시간이 달라져서 제대로 GPS정보를 가져올 수 없는 경우들이 있습니다. OTG케이블을 이용해서 메모리카드와 핸드폰을 연결하는것을 추천합니다.
   Connect the memory card of your digital camera and smartphone. I recommend you connect to use OTG cable and smartphone.

5. 갤러리에 들어가서 GPS 정보를 넣을 사진을 선택한 한 후에 공유버튼을 누르고 "위치저장" 메뉴를 선택합니다.
   Run the Gallery app and select pictures.
   Select share button and select the geotagging to write GPS information.


6. 잠시 기다리면 자동으로 사진에 위치정보를 기록해 줍니다. 사진의 개수가 많을 때는 오래 걸립니다.
   Please wait... If you have many selected pictures, it takes a long time.


7. gpslogger라는 폴더에 위치정보가 기록된 사진들을 찾을 수 있습니다.
   You can find your pictures with GPS information at gpslogger folder.


[Android] 이클립스(Eclipse)에서 Tesseract Open Source OCR Engine 사용하기 #1

윈도우즈 Eclipse 개발 환경에서 OCR 오픈 소스인 Tesseract를 사용해서 안드로이드 어플리케이션을 만드는 방법을 설명합니다.

1. 준비사항
① Eclipse를 사용한 안드로이드 개발환경
② NDK Download
③ Tesseract Download

2. Tesseract 빌드
Tesseract 오픈 소스는 JNI 소스를 포함 하고 있어서 라이브러리로 사용하기 위해서 Android NDK 를 이용해서 빌드를 해야 합니다. 아래는 이 과정을 설명합니다.

① File→Import... 를 통해서 tess-two Project 생성


② tess-two Project→Properties→Builders→New→Program→OK
③ Main 탭 설정
- Name : NDK Builder
- Location : ndk-build.cmd 가 있는 경로(Browse File System...을 눌러서 설정)
- Working Directory : tess-two 프로젝트 선택 (Browse Workspace...를 눌러서 설정)
④ Refresh 탭 설정
- Specific resources 선택
- tess-two/libs 폴더가 없으면 새로 생성한 후 선택합니다.

⑤ Build Options 탭 설정
- Allocate Console 체크
- After a "Clear" 체크
- During manual builds 체크
- During auto builds 체크
- Specify Resources 를 tess-two/jni 선택
⑥ Menu→Project→Build Project 를 선택해서 Build 시작한 후에 libs 폴더에 *.so 파일들이 생성되어 있으면 성공한 것 입니다.

3. Reference
① http://gaut.am/making-an-ocr-android-app-using-tesseract/

[Android] 이클립스(Eclipse)에서 Tesseract Open Source OCR Engine 사용하기 #2

Tesseract 오픈소스를 이용해서 실제 문자인식을 하는 안드로이드 어플리케이션을 만들어 보겠습니다.

1. 준비사항
① Eclipse를 사용한 안드로이드 개발환경
② tesseract 라이브러리 Open
③ Simple Android OCR Download

2. Simple Android OCR 만들기
① File→Import... 를 통해서 Simple-Android-OCR Project 생성

② Simple-Android-OCR Project→Properties→Android tess-two 라이브러리가 정상적으로 Add 되었는지 확인

③ 빌드 후에 실행 하면 됩니다.




3. Reference
① http://gaut.am/making-an-ocr-android-app-using-tesseract/