This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

*/
레이블이 VSCode인 게시물을 표시합니다. 모든 게시물 표시
레이블이 VSCode인 게시물을 표시합니다. 모든 게시물 표시

VSCode에서 launch.json 혹은 task.json에서 활용할 수 있는 사전에 정의된 변수들

미리 정의된 변수

다음과 같은 미리 정의된 변수가 지원됩니다.

  • ${userHome} - 사용자의 홈 폴더 경로
  • ${workspaceFolder} - VS Code에서 열린 폴더의 경로
  • ${workspaceFolderBasename} - 슬래시(/) 없이 VS Code에서 열린 폴더의 이름
  • ${file} - 현재 열린 파일
  • ${fileWorkspaceFolder} - 현재 열린 파일의 작업 공간 폴더
  • ${relativeFile} - 현재 열린 파일에 상대적인 파일workspaceFolder
  • ${relativeFileDirname} - 현재 열려 있는 파일의 상대 디렉터리 이름workspaceFolder
  • ${fileBasename} - 현재 열린 파일의 기본 이름
  • ${fileBasenameNoExtension} - 파일 확장자가 없는 현재 열린 파일의 기본 이름
  • ${fileExtname} - 현재 열린 파일의 확장자
  • ${fileDirname} - 현재 열린 파일의 폴더 경로
  • ${fileDirnameBasename} - 현재 열린 파일의 폴더 이름
  • ${cwd} - VS Code 시작 시 작업 실행기의 현재 작업 디렉터리
  • ${lineNumber} - 활성 파일에서 현재 선택된 줄 번호
  • ${selectedText} - 활성 파일에서 현재 선택된 텍스트
  • ${execPath} - 실행 중인 VS Code 실행 파일의 경로
  • ${defaultBuildTask} - 기본 빌드 작업의 이름
  • ${pathSeparator} - 파일 경로에서 구성 요소를 구분하기 위해 운영 체제에서 사용하는 문자

미리 정의된 변수 예

다음과 같은 요구 사항이 있다고 가정합니다.

  1. VSCode에서 작업공간으로 Open한 디렉토리가 c:/home/your-project이고,
  2. 편집기에 열린 파일이 c:/home/your-project/folder/file.ext일때,

따라서 각 변수에 대해 다음 값을 갖게 됩니다.

  • ${userHome} -c:/home/your-home혹은, 설치된 디렉토러리
  • ${workspaceFolder} -c:/home/your-project
  • ${workspaceFolderBasename} -your-project
  • ${file} -c:/home/your-project/folder/file.ext
  • ${fileWorkspaceFolder} -c:/home/your-project
  • ${relativeFile} -folder/file.ext
  • ${relativeFileDirname} -folder
  • ${fileBasename} -file.ext
  • ${fileBasenameNoExtension} -file
  • ${fileDirname} -c:/home/your-project/folder
  • ${fileExtname} -.ext
  • ${lineNumber} - 커서의 줄 번호
  • ${selectedText} - 코드 편집기에서 선택된 텍스트
  • ${execPath} - Code.exe의 위치
  • ${pathSeparator} - /macOS 또는 Linux, \Window


관련글

참고 

Python으로 QR Code Reader 만들기

개발 환경

  • Windows 10
  • VisualStudio Code
  • Python : 3.7.9

QR Code를 읽을 수 있는 프로그램을 찾다가 아래 참조에서 찾은 코드를 소개 한다. 기존 개발 환경 VS Code에서 바로 테스트 할 수 있다. 

필요한 파이썬 라이브러리

  • OpenCV : 이미지 처리, 컴퓨터 비젼 및 기계 학습 라이브러리
  • Numpy : 행렬이나 일반적으로 대규모 다차원 배열을 쉽게 처리 할 수 있도록 지원하는  라이브러리
  • pyzbar : 주어진 이미지에서 Bar code, QR Code를 읽는다. EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 및 QR Code를 지원

라이브러리 설치

  • OpenCV 설치
   > pip install opencv-python                                          

       혹은  

   > pip install opencv-contrib-python                                  
  •  numpy 설치
   > pip install numpy                                                  
  • pyzbar 설치

       > pip install pyzbar                                                 

    코드

    • 필요 라이브러리 import
    • import cv2
      import numpy as np
      from pyzbar.pyzbar import decode

      • 카메라로부터 이미지 캡쳐 
      • cap = cv2.VideoCapture(0)
        while True:
            ret, frame = cap.read()
            decoder(frame)
            cv2.imshow('Image', frame)
            code = cv2.waitKey(10)
            if code == ord('q'):
                break
        •  주어진 이미지로부터 QR Code를 얻는 함수 
        • def decoder(image):
              gray_img = cv2.cvtColor(image,0)
              barcode = decode(gray_img)

              for obj in barcode:
                  points = obj.polygon
                  (x,y,w,h) = obj.rect
                  pts = np.array(points, np.int32)
                  pts = pts.reshape((-1, 1, 2))
                  cv2.polylines(image, [pts], True, (0, 255, 0), 3)

                  barcodeData = obj.data.decode("utf-8")
                  barcodeType = obj.type
                  string = "Data " + str(barcodeData) + " | Type " + str(barcodeType)
                 
                  cv2.putText(frame, string, (x,y), cv2.FONT_HERSHEY_SIMPLEX,0.8,(255,0,0), 2)
                  print("Barcode: "+barcodeData +" | Type: "+barcodeType)

          •  최종 코드  
          • cap = cv2.VideoCapture(0)
            while True:
            import cv2
            import numpy as np
            from pyzbar.pyzbar import decode

            def decoder(image):
                gray_img = cv2.cvtColor(image,0)
                barcode = decode(gray_img)

                for obj in barcode:
                    points = obj.polygon
                    (x,y,w,h) = obj.rect
                    pts = np.array(points, np.int32)
                    pts = pts.reshape((-1, 1, 2))
                    cv2.polylines(image, [pts], True, (0, 255, 0), 3)

                    barcodeData = obj.data.decode("utf-8")
                    barcodeType = obj.type
                    string = "Data " + str(barcodeData) + " | Type " + str(barcodeType)
                   
                    cv2.putText(frame, string, (x,y), cv2.FONT_HERSHEY_SIMPLEX,0.8,(255,0,0), 2)
                    print("Barcode: "+barcodeData +" | Type: "+barcodeType)

            cap = cv2.VideoCapture(0)
            while True:
                ret, frame = cap.read()
                decoder(frame)
                cv2.imshow('Image', frame)
                code = cv2.waitKey(10)
                if code == ord('q'):
                    break

          참조 

          Visual Studio Code에서 arduino 사용하기

          Visual Studio Code에서 arduino를 위한 확장 설치

          설치순서


          1.확장탭을 누르고 2.검색창에 "arduino"를 입력하면 arduino관련된 확장모듈이 검색된다. 첫번째로 검색된 Microsoft에서 나온 Arduino 확장의 3. install버튼을 클릭한다.

          전제조건

          Arduino IDE 필요. (다운로드 에서 arduino IDE를 다운받아 설치)

          Visual Studio Code 설정

          VS Code에서  < Ctrl > + < , > 두키를 동시에 누르면 Search settings 메뉴가 표출된다 여기에서 Extensions > Arduino configuration 을 선택하고 

          아래와 같이 Edit in settings.json를 편집한다.
          {
              "arduino.path""C:/Program Files (x86)/Arduino",
              "arduino.commandPath""arduino_debug.exe",
              "arduino.logLevel""info",
              "arduino.allowPDEFiletype"false
              "arduino.enableUSBDetection"true,
              "arduino.disableTestingOpen"false,
              "arduino.skipHeaderProvider"false,
              "arduino.additionalUrls": [
                  "https://raw.githubusercontent.com/VSChina/azureiotdevkit_tools/master/package_azureboard_index.json",
                  "http://arduino.esp8266.com/stable/package_esp8266com_index.json"
              ],
              "arduino.defaultBaudRate"115200
          }
          "arduino.path" 는 위에서 arduino IDE를 설치한 디렉토리를 기재하여야 한다.

          Commands

          • Arduino: Board Manager: Manage packages for boards. You can add 3rd party Arduino board by configuring Additional Board Manager URLs in the board manager.
          • Arduino: Change Baud Rate: Change the baud rate of the selected serial port.
          • Arduino: Change Board Type: Change board type or platform.
          • Arduino: Close Serial Monitor: Stop the serial monitor and release the serial port.
          • Arduino: Examples: Show list of examples.
          • Arduino: Initialize: Scaffold a VS Code project with an Arduino sketch.
          • Arduino: Library Manager: Explore and manage libraries.
          • Arduino: Open Serial Monitor: Open the serial monitor in the integrated output window.
          • Arduino: Select Serial Port: Change the current serial port.
          • Arduino: Send Text to Serial Port: Send a line of text via the current serial port.
          • Arduino: Upload: Build sketch and upload to Arduino board.
          • Arduino: Upload Using Programmer: Upload using an external programmer.
          • Arduino: Verify: Build sketch.

          Reference

          관련문서