반응형

pip install pytesseract

 

한글팩 : https://github.com/tesseract-ocr/tessdata/

 
다운 받아야하는 학습된 한글 데이터 파일명: kor.traineddata
파일 위치: tesseract가 설치된 경로 C:\Program Files\Tesseract-OCR\tessdata
 

*** 설치 할때 언어팩 선택 

 

pytesseract 0.3.10

 

Python-tesseract is an optical character recognition (OCR) tool for python. That is, it will recognize and “read” the text embedded in images.

Python-tesseract is a wrapper for Google’s Tesseract-OCR Engine. It is also useful as a stand-alone invocation script to tesseract, as it can read all image types supported by the Pillow and Leptonica imaging libraries, including jpeg, png, gif, bmp, tiff, and others. Additionally, if used as a script, Python-tesseract will print the recognized text instead of writing it to a file.

USAGE

Quickstart

Note: Test images are located in the tests/data folder of the Git repo.

Library usage:

from PIL import Image

import pytesseract

# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'
# Example tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR\tesseract'

# Simple image to string
print(pytesseract.image_to_string(Image.open('test.png')))

# In order to bypass the image conversions of pytesseract, just use relative or absolute image path
# NOTE: In this case you should provide tesseract supported images or tesseract will return error
print(pytesseract.image_to_string('test.png'))

# List of available languages
print(pytesseract.get_languages(config=''))

# French text image to string
print(pytesseract.image_to_string(Image.open('test-european.jpg'), lang='fra'))

# Batch processing with a single file containing the list of multiple image file paths
print(pytesseract.image_to_string('images.txt'))

# Timeout/terminate the tesseract job after a period of time
try:
    print(pytesseract.image_to_string('test.jpg', timeout=2)) # Timeout after 2 seconds
    print(pytesseract.image_to_string('test.jpg', timeout=0.5)) # Timeout after half a second
except RuntimeError as timeout_error:
    # Tesseract processing is terminated
    pass

# Get bounding box estimates
print(pytesseract.image_to_boxes(Image.open('test.png')))

# Get verbose data including boxes, confidences, line and page numbers
print(pytesseract.image_to_data(Image.open('test.png')))

# Get information about orientation and script detection
print(pytesseract.image_to_osd(Image.open('test.png')))

# Get a searchable PDF
pdf = pytesseract.image_to_pdf_or_hocr('test.png', extension='pdf')
with open('test.pdf', 'w+b') as f:
    f.write(pdf) # pdf type is bytes by default

# Get HOCR output
hocr = pytesseract.image_to_pdf_or_hocr('test.png', extension='hocr')

# Get ALTO XML output
xml = pytesseract.image_to_alto_xml('test.png')

Support for OpenCV image/NumPy array objects

import cv2

img_cv = cv2.imread(r'/<path_to_image>/digits.png')

# By default OpenCV stores images in BGR format and since pytesseract assumes RGB format,
# we need to convert from BGR to RGB format/mode:
img_rgb = cv2.cvtColor(img_cv, cv2.COLOR_BGR2RGB)
print(pytesseract.image_to_string(img_rgb))
# OR
img_rgb = Image.frombytes('RGB', img_cv.shape[:2], img_cv, 'raw', 'BGR', 0, 0)
print(pytesseract.image_to_string(img_rgb))

If you need custom configuration like oem/psm, use the config keyword.

# Example of adding any additional options
custom_oem_psm_config = r'--oem 3 --psm 6'
pytesseract.image_to_string(image, config=custom_oem_psm_config)

# Example of using pre-defined tesseract config file with options
cfg_filename = 'words'
pytesseract.run_and_get_output(image, extension='txt', config=cfg_filename)

Add the following config, if you have tessdata error like: “Error opening data file…”

# Example config: r'--tessdata-dir "C:\Program Files (x86)\Tesseract-OCR\tessdata"'
# It's important to add double quotes around the dir path.
tessdata_dir_config = r'--tessdata-dir "<replace_with_your_tessdata_dir_path>"'
pytesseract.image_to_string(image, lang='chi_sim', config=tessdata_dir_config)

Functions

  • get_languages Returns all currently supported languages by Tesseract OCR.
  • get_tesseract_version Returns the Tesseract version installed in the system.
  • image_to_string Returns unmodified output as string from Tesseract OCR processing
  • image_to_boxes Returns result containing recognized characters and their box boundaries
  • image_to_data Returns result containing box boundaries, confidences, and other information. Requires Tesseract 3.05+. For more information, please check the Tesseract TSV documentation
  • image_to_osd Returns result containing information about orientation and script detection.
  • image_to_alto_xml Returns result in the form of Tesseract’s ALTO XML format.
  • run_and_get_output Returns the raw output from Tesseract OCR. Gives a bit more control over the parameters that are sent to tesseract.

Parameters

image_to_data(image, lang=None, config='', nice=0, output_type=Output.STRING, timeout=0, pandas_config=None)

  • image Object or String - PIL Image/NumPy array or file path of the image to be processed by Tesseract. If you pass object instead of file path, pytesseract will implicitly convert the image to RGB mode.
  • lang String - Tesseract language code string. Defaults to eng if not specified! Example for multiple languages: lang='eng+fra'
  • config String - Any additional custom configuration flags that are not available via the pytesseract function. For example: config='--psm 6'
  • nice Integer - modifies the processor priority for the Tesseract run. Not supported on Windows. Nice adjusts the niceness of unix-like processes.
  • output_type Class attribute - specifies the type of the output, defaults to string. For the full list of all supported types, please check the definition of pytesseract.Output class.
  • timeout Integer or Float - duration in seconds for the OCR processing, after which, pytesseract will terminate and raise RuntimeError.
  • pandas_config Dict - only for the Output.DATAFRAME type. Dictionary with custom arguments for pandas.read_csv. Allows you to customize the output of image_to_data.

CLI usage:

pytesseract [-l lang] image_file

INSTALLATION

Prerequisites:

  • Python-tesseract requires Python 3.6+
  • You will need the Python Imaging Library (PIL) (or the Pillow fork). Under Debian/Ubuntu, this is the package python-imaging or python3-imaging.
  • Install Google Tesseract OCR (additional info how to install the engine on Linux, Mac OSX and Windows). You must be able to invoke the tesseract command as tesseract. If this isn’t the case, for example because tesseract isn’t in your PATH, you will have to change the “tesseract_cmd” variable pytesseract.pytesseract.tesseract_cmd. Under Debian/Ubuntu you can use the package tesseract-ocr. For Mac OS users. please install homebrew package tesseract.
  • Note: In some rare cases, you might need to additionally install tessconfigs and configs from tesseract-ocr/tessconfigs if the OS specific package doesn’t include them.
Installing via pip:

Check the pytesseract package page for more information.

pip install pytesseract
Or if you have git installed:
pip install -U git+https://github.com/madmaze/pytesseract.git
Installing from source:
git clone https://github.com/madmaze/pytesseract.git
cd pytesseract && pip install -U .
Install with conda (via conda-forge):
conda install -c conda-forge pytesseract

TESTING

To run this project’s test suite, install and run tox. Ensure that you have tesseract installed and in your PATH.

pip install tox
tox

반응형
반응형

 

 

https://www.theverge.com/2024/1/29/24055011/meta-llama2-code-generator-generative-ai

 

삽화: Alex Castro / The Verge

코드 생성 AI 모델인 Code Llama 70B 에 대한 Meta의 최신 업데이트는 아직까지 "가장 크고 성능이 뛰어난 모델"입니다. Code Llama 도구는 8월에 출시되었으며 연구 및 상업용 모두 무료입니다. Meta의 AI 블로그 게시물에 따르면 Code Llama 70B는 이전 버전보다 더 많은 쿼리를 처리할 수 있습니다. 이는 개발자가 프로그래밍하는 동안 더 많은 프롬프트를 제공할 수 있고 더 정확할 수 있음을 의미합니다.

Code Llama 70B는 HumanEval 벤치마크에서 정확도 53%를 기록하여 GPT-3.5의 48.1%보다 나은 성능을 보였고 GPT-4에 대해 보고된 OpenAI 문서 (PDF) 의 67%에 더 가깝습니다 .

 

Llama 2를 기반으로 구축된 Code Llama는 개발자가 프롬프트에서 코드 문자열을 생성하고 사람이 작성한 작업을 디버깅하는 데 도움이 됩니다. Meta는 지난 가을에 특정 코딩 언어에 초점을 맞춘 두 가지 다른 Code Llama 도구인 Code Llama - Python과 Code Llama - Instruct를 동시에 출시했습니다.

Code Llama 70B는 세 가지 버전의 코드 생성기에서 사용할 수 있으며 연구 및 상업적 용도로는 여전히 무료입니다. 대규모 모델은 1TB의 코드 및 코드 관련 데이터에 대해 학습되었습니다. AI 모델을 실행하기 위해 GPU에 대한 액세스를 제공하는 코드 저장소 Hugging Face에서 호스팅됩니다.

Meta는 자사의 대형 모델인 34B 및 70B가 "최고의 결과를 반환하고 더 나은 코딩 지원을 제공합니다"라고 말했습니다.

다른 AI 개발자들은 작년에 코드 생성기를 출시했습니다. Amazon의 CodeWhisperer는 4월에 출시되었으며 Microsoft는 OpenAI의 모델을 활용하여 GitHub Copilot을 출시했습니다 

반응형
반응형

비전 프로 출시 D-2

Vision Pro Review: 24 Hours With Apple’s Mixed-Reality Headset | WSJ

 

https://www.youtube.com/watch?v=8xI10SFgzQ8

실리콘밸리 시간으로는 3일, 한국시간으로는 2일 후 애플의 신형 디바이스인 비전 프로가 판매를 드디어 시작하는데요. 미국의 미디어 유튜버들의 제품 리뷰와 영상이 본격적으로 공개되기 시작했어요. 유튜브나 뉴스검색을 통해서 찾아보실 수 있는데요. 리뷰어들의 소감 중에서 재미있는 것을 정리해봤어요. 

 

  • 무겁다 : 실제 무게도 있지만 메타 퀘스트와 달리 무게가 앞에 쏠려있는 점이 문제.
  • 가상 키보드는 별로 : 비전 프로로 일을 하고 싶다면 실물 키보드를 추천.
  • 안경은 못쓴다 : 안경을 쓰고 착용하기 어렵기 때문에 도수가 있는 렌즈를 별도로 구매해서 부착해야해요.  
  • 놀라운 디스플레이 : 디스플레이 성능이 너무 좋은데 이것이 높은 가격의 가장 큰 원인 중 하나. 
  • 패스스루도 완벽 : 비전 프로를 착용해도 카메라를 통해서 외부를 보는 혼합현실(Mixed Reality)기능이 매우 훌륭하다고 해요. 
  • 시리를 많이 사용하게 된다 : 음성 AI 비서인 시리가 비전프로에서도 당연히 작동을 하는데, 비전프로를 쓰고 있는 환경에서는 자연스럽게 시리를 호출해서 명령을 내리는 경우가 많아요. 마치 아이언맨이 자비스를 부르는 것 처럼요.  
  • 3D 영상 촬영이 킬러 서비스 : 아이폰15 프로로 공간동영상(Spatial)을 촬영할 수 있는데, 이걸 비전 프로에서 볼 수 있어요. 많은 리뷰어들이 여기에 만족을 나타냈어요. 2D 영상을 보는 것보다 과거의 경험을 다시 생생하게 느낄 수 있다고 해요. 특히 아이의 영상을 찍은 부모들의 만족도가 높았어요. 과거 캠코더가 아이들의 영상을 찍기 위해 많은 부모들이 샀던 것처럼 비전 프로 수요도 있을 것 같아요.  
  • 침대에 누워서 쓰기 좋다 : 침대에서 스마트폰을 쓰는 분들이 많은데, 비전 프로를 쓰면 무게도 덜 느끼고 좋을 것 같아요.

패스스루란?

패스스루는 VR 화면에서 벗어나 주변의 실제 환경을 볼 수 있게 해주는 기능입니다. 패스스루는 헤드셋의 센서를 사용하여 사용자가 헤드셋 너머의 실제 환경을 본다고 가정했을 때 보게 될 환경을 대략적으로 보여줍니다. 안전 보호 경계를 만들거나 조정할 때 자동으로 패스스루가 작동합니다. 실제 및 가상 환경을 혼합하기 위해 앱에도 패스스루가 표시됩니다.

반응형
반응형

우선 사용자가 페이지 안에서 스크롤을 사용해 이동하는 경우 어떤 방법을 사용할까요?

1.마우스의 휠 버튼을 사용하는 경우
2.키보드의 커서키를 사용하는 방법
3.스크롤 바 위에 마우스를 올려 드래그하여 이동하는 방법


이처럼 세가지 방법이 가장 보편적입니다. 이 중에서 오늘은 스크롤을 사용한 이동시 이를 블락하는 방법을 알아보겠습니다. 먼저 스크롤을 막는 것이 왜? 그리고 언제 필요할까요?

# 스크롤의 이동을 막는 것이 필요한 경우
언제 스크롤을 사용한 페이지 이동을 막아야할까요? 먼저 중요한 콘텐츠 화면 영역에서 빠른 스크롤 이동에 의하여 의도한 콘텐츠를 다 못보여주는 경우도 생각해볼 수 있습니다. 이런 경우는 예를 들면... 페이지 스크롤에 따라 화면이 동적으로 변하는 웹사이트의 경우가 이에 해당합니다. 동적으로 변하는 웹사이트를 보여주기 위해 사용자의 스크롤 이동을 강제하는 것이 필요할 수 있습니다.

또 다른 이유로 스크롤이 화면에 고정되야 하는 경우입니다. 햄버거 버튼을 누른 뒤거나 아니면 모달 형식의 팝업창을 띄운 경우가 좋은 예 입니다.



# 스크롤을 고정하는 방법 예제 소스보기
아래의 소스 코드를 봐주세요. 이코드는 스크립트와 CSS를 사용하여 사용자의 페이지 이동을 강제적으로 막고 있습니다. 우선 스크롤이 생기지 않게 하기 위하여 html과 body 태그에 overflow 속성을 사용하였고 그 값으로 hidden을 주었습니다.

또한 해당하는 요소의 브라우저 기본 이벤트를 피하기 위해 아래의 이벤트 함수를 사용합니다. preventDefault()는 이벤트 내장함수의 실행을 막아 의도한 동작만을 방문자에게 보여줍니다. 또한 발생 가능한 아벤트 버블링을 피하기 위해 stopPropagation()을 추가하였습니다. 해당 자바스크립트는 아래와 같이 사용합니다.
event.preventDefault();
event.stopPropagation();

아래 코드를 직접 실행해 보면서 익혀보시기 바랍니다. 코드는 제이쿼리(jQuery)를 사용하여 만든 예제소스입니다.
$('html, body').css({'overflow': 'hidden', 'height': '100%'});
$('#element').on('scroll touchmove mousewheel', function(event) {
  event.preventDefault();
  event.stopPropagation();
  return false;
});

위 코드는 스크롤과 터치이동, 마우스휠의 이벤트 발생시 동작하지 않도록 제거합니다. 각각 scrolll, touchmove, mousewheel 이벤트 코드가 추가되어 있습니다.


# 스크롤 이동을 다시 허용하기
만약 다시 스크롤을 허용해야한다면? 이 경우 기존의 마우스 스크롤이벤트의 핸들러를 제거해야하므로 해제방법이 필요할 것입니다. 이때는 등록된 이벤트를 해제하여 주는 off() 메소드를 사용하여 가능합니다. 아래 코드의 예제를 봐주세요.
$('#element').off('scroll touchmove mousewheel');

여기까지 스크롤의 사용자 화면전환을 강제로 막는 방법을 알아보았습니다.



http://relation.co.kr/images_board/board_system_publishing/211/index.php/

반응형
반응형

R&R을 뛰어 넘어라

 

기업이 커지면 커질수록 분란의 싹이 함께 커집니다. 스타트업일 때는 동료들이 이일 저일 미루지 않고 함께 하지만, 조직이 커지면 위계질서가 만들어지고, 역할 분장이 명료해집니다. 드디어 직원들에겐 R&R(Role & Responsibility)이 부여됩니다. "이것은 네 일, 저것은 내 일" 하지만 기업은 늘 신사업을 찾다보니 갈등이 벌어집니다. 리더가 R&R을 매번 바꿔 줘야 하지만, 현실은 그렇지 못하니까요. 예를 들어,

 

  • 👩옆 팀장: 좀 도와줄 수 있나요? 우리 팀에서 새 업무를 아는 사람이 없는데
  • 🤫: 할 수 있을 것 같은데요. 일단 저희 팀장께 물어보고 답변 드릴게요.
  • 👦내 팀장: 책임님이 옆 팀 일을 거드시면 저희 팀 업무는 언제 하시려고요.
  • 😟: (어떻게 해야하지...ㅠㅠ)

 

R&R  

이러한 R&R을 도입한 것은 1920년대 제너럴 일렉트릭(GE)으로 알려졌어요. 당시 CEO인 앨프레드 P. 슬로언이 조직 개편을 주도하면서 각 부서와 직위에 따른 R&R을 정립했습니다. 업무 범위를 명확히 하고, 책임 한계를 설정했어요. 당시에는 파격이었습니다. 부서장이 내리는 업무외적 불필요한 명령을 차단하고, 회사 존립 목적 자체에 집중하도록 했기 때문인데요.

 

하지만 오늘날처럼 산업이 역동적으로 바뀌는 때에는 적합하지 않다는 지적이 있습니다. 그러다 보니 일 잘 하는 사람, 말 못하는 사람들이 여러 일을 떠안기 일쑤입니다. 회사에서 업무를 정의하면 크게 두 가지입니다. E&E!

 

E&E!

우선 Exploitation 활용은 품질과 프로세스 개선 등을 빠르고 효율적으로 하는 것을 가리킵니다. 반면 Exploration 탐험은 새로운 가능성에 대한 탐구입니다.

 

Exploitation이 현재 업무를 개선하고 나아가는 것이라면, Exploration은 신 사업을 찾아 떠나는 여정입니다. 오늘날은 이를 어떻게 조화롭게 구성할지가 관건인데요. 몇몇 기업들은 이를 비율로 만들어 둡니다.

 

구글: 20% 타임제

구글은 직원이 여유 시간이 있어야 Exploration이 가능하다고 판단해요. 그래서 20% 타임제를 두고 있습니다. (물론 120% 야근제 아니냐는 지적도...) 구글은 80%는 본업을 하고, 20%, 즉 일주일에 하루 정도는 현재 수행하고 있는 업무와 전혀 관련이 없는 활동을 하도록 장려합니다. 그 결과 구글 뉴스, 애드센스 포 콘텐츠, 구글 서제스트 등이 태어났습니다.

 

3M: 15%

스카치 테이프로 유명한 3M 역시 15%룰을 운영합니다. 일부 부서에 국한된 이야기이긴 한데요. 연구 조직은 자신의 업무 시간 중 15%를 업무와 무관한 프로젝트에 사용할 수 있습니다. 또 프로젝트가 실패하더라도, 책임이나 이유를 따지지 않습니다. 그 결과, 우리가 흔히 쓰는 포스트-잇이 태어났어요.

 

🔎크게보기

R&R을 놓고 선배들과 후배들 간 견해차이가 큽니다. 선배들은 그렇게 업무를 명확히 구분하면, 어떻게 회사가 굴러가느냐고 하지만, 후배들은 명확하지 않다면, 공정하지 않다고 여깁니다. 개인적으로는 조직이 크면 클수록 업무가 명확한 게 좋다고 생각합니다. 그렇지 않으면, 인재들이 불만을 품기 때문인데요.

 

하지만 조직이 경직화되는 것은 경계해야합니다. 꽉 막힌 조직은 더디게 성장하기 때문입니다. 중요한 것은 조직 전체가 어떻게 하면, 효율적으로, 창의적으로, 꿈틀대게 할지 다 같이 고민할 수 있는 공동체 정신 아닐까 합니다.

 

https://stibee.com/api/v1.0/emails/share/EkB2Zdv2mId7G7lF066P6JmtpdRFblA

반응형
반응형

Top 30 JavaScript Interview Questions and Answers for 2024

 

https://javascriptcentric.medium.com/top-30-javascript-interview-questions-and-answers-for-2024-7f1e2d1d0638

 

Top 30 JavaScript Interview Questions and Answers for 2024

Prepare for your next JavaScript interview with confidence!

javascriptcentric.medium.com

 

Level-1: Basic

1. Is Javascript single-threaded?

2. Explain the main component of the JavaScript Engine and how it works.

3. Explain the event loop in JavaScript and how it helps in asynchronous programming.

4. Difference between var, let, and const ?

5. Different data types in Javascript?

6. What is callback function and callback hell ?

7. What is Promise and Promise chaining?

8. What is async/await ?

9.What is the difference between == and === operators ?

10. Different ways to create an Object in Javascript ?

11. What is rest and spread operator?

12. What is a higher-order function?

Level-2 : Intermediate

13. What is Closure? What are the use cases of Closures?

14. Explain the concept of hoisting in JavaScript.

15. What is a Temporal dead zone?

16. What is a prototype chain? and Object.create() method?

17. What is the difference between Call, Apply, and Bind methods?

18. What are lambda or arrow functions?

19. What is the currying function?

20. What are the features of ES6?

Level-3: Expert

21. What is Execution context, execution stack, variable object, scope chain?

22. What is the priority of execution of callback, promise, setTimeout, process.nextTick()?

23. What is the Factory function and generator function?

24. Different ways to clone (Shallow and deep copy of object) an object?

25. How to make an object immutable? (seal and freeze methods)?

26. What is Event and event flow, event bubbling and event capturing?

27. What is Event delegation?

28. What are server-sent events?

29. What is a web worker or service worker in javascript?

30. How to compare 2 JSON objects in javascript?

반응형
반응형

[MSSQL] 테이블 정보 확인

 

테이블 컬럼 정보 확인

select * from information_schema.columns

where table_name = ''

 

테이블 제약조건 확인 

select

*

from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE

where table_name = ''

 

테이블 인덱스 확인 확인 

SELECT * FROM sys.dm_db_index_physical_stats

 

반응형
반응형

[MSSQL] CHARINDEX 두개의 문자 에서 문자 찾기 

 

CHARINDEX(Transact-SQL)

이 함수는 두 번째 문자 식 내에서 하나의 문자 식을 찾고, 있는 경우 첫 번째 식의 시작 위치를 반환합니다.

 

DECLARE @document VARCHAR(64);  
SELECT @document = 'Reflectors are vital safety' +  
                   ' components of your bicycle.';  
SELECT CHARINDEX('bicycle', @document);  



-----------   
48

 

반응형

+ Recent posts