[ 작성 중 ]
'Computer > Windows' 카테고리의 다른 글
windows 환경에서 tar.gz 압축을 해제하자 (0) | 2023.07.31 |
---|---|
windows 11 작업표시줄 시계 크기 오류를 해결하자 (0) | 2022.10.05 |
프린터 용지 부족 문제를 해결하자 (0) | 2022.04.11 |
작업표시줄 미리보기를 리스트로 변경하자 (0) | 2022.02.07 |
창 흔들어 최소화 기능 끄기 (0) | 2021.01.27 |
[ 작성 중 ]
windows 환경에서 tar.gz 압축을 해제하자 (0) | 2023.07.31 |
---|---|
windows 11 작업표시줄 시계 크기 오류를 해결하자 (0) | 2022.10.05 |
프린터 용지 부족 문제를 해결하자 (0) | 2022.04.11 |
작업표시줄 미리보기를 리스트로 변경하자 (0) | 2022.02.07 |
창 흔들어 최소화 기능 끄기 (0) | 2021.01.27 |
skvideo.io 를 사용하던 도중
AssertionError: Cannot find installation of real FFmpeg (which comes with ffprobe).
vread시 위와 같은 에러를 만났다.
이럴 경우 ffmpeg를 설치해주면 정상적으로 vread를 사용할 수 있다.
>> conda install ffmpeg -c mrinaljain17
module 'distutils' has no attribute 'version' 에러를 해결하자 (0) | 2023.07.31 |
---|---|
No module named '_overlapped' 문제를 해결하자 (1) | 2022.11.01 |
windows terminal(powershell) 에서도 conda를 사용하자 (0) | 2022.08.02 |
vscode terminal 에 conda를 연결하자 (0) | 2022.07.06 |
vscode에 conda 가상환경을 연결하자. (0) | 2022.07.06 |
$ conda config --set ssl_verify False
(내 경우는 이 방법으로 해결 안됨..해결 후 업데이트 예정.)
[WSL2] 경로를 windows 탐색기에서 확인하자. (0) | 2023.08.24 |
---|---|
[Git] github -> gitlab / repository를 이사하자 (0) | 2021.12.06 |
[ROS] Rosbag2Video (0) | 2021.11.30 |
float 값의 비교 (== 연산자는 위험하다!) (0) | 2021.04.13 |
google drive web client 사용량 제한 (0) | 2021.02.25 |
일반적으로 command prompt 를 사용하다 powershell을 사용 해 보기 시작했다.
그러나 powershell 환경에서는 conda가 적용되어 있지 않아
powershell 에서 conda를 사용하는 방법을 기록.
0. conda 설치 및 환경변수 설정은 cmd에서 미리 했다고 치고...
1. powershell 환경에서 conda init
conda init powershell
2. (관리자모드 필요) 로컬시스템 실행 정책 업데이트
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
3. powershell 재시작
No module named '_overlapped' 문제를 해결하자 (1) | 2022.11.01 |
---|---|
skvideo vread 시 FFmpeg 관련 에러를 해결하자 (0) | 2022.09.02 |
vscode terminal 에 conda를 연결하자 (0) | 2022.07.06 |
vscode에 conda 가상환경을 연결하자. (0) | 2022.07.06 |
vscode keymap을 변경하자 (0) | 2022.07.06 |
이전글에서 vscode에 가상환경을 연결하는 것까지는 설정했다.
그러나 ctrl + ` 를 이용하여 터미널을 열 경우 conda가 연결되지 않는 현상이 있어서
터미널에 conda 환경을 연결하는 방법을 기록.
1. 시스템 환경변수 path 에 conda path 설정
- {conda root}
- {conda root}/Library
- {conda root}/Scripts
2. default terminal 변경 (default termianl이 windows powershell인 경우)
- command palatte - Terminal: Select Default Profile 선택
- Command Prompt 선택
skvideo vread 시 FFmpeg 관련 에러를 해결하자 (0) | 2022.09.02 |
---|---|
windows terminal(powershell) 에서도 conda를 사용하자 (0) | 2022.08.02 |
vscode에 conda 가상환경을 연결하자. (0) | 2022.07.06 |
vscode keymap을 변경하자 (0) | 2022.07.06 |
골뱅이 연산자의 의미 (행렬곱). (0) | 2022.05.09 |
conda 가상환경을 구축하여 사용중이고 IDE로 pycharm을 주로 사용하다
vscode도 사용하기 위해 설치 후 가상환경을 연결하는 방법을 기록.
1. command palette (ctrl + shift + p)
2. Python: Select Interpreter
3. 사용하고자 하는 가상환경 선택
windows terminal(powershell) 에서도 conda를 사용하자 (0) | 2022.08.02 |
---|---|
vscode terminal 에 conda를 연결하자 (0) | 2022.07.06 |
vscode keymap을 변경하자 (0) | 2022.07.06 |
골뱅이 연산자의 의미 (행렬곱). (0) | 2022.05.09 |
예쁘게 출력하자 pprint - pretty print (0) | 2022.03.16 |
기본적으로 vscode keymap이 visual studio와 다른 부분이 있다.
visual studio keymap 에 익숙해진 나로써는 불편한 부분이 있어 keymap 변경을 위한 방법을 기록.
1. vscode 설치 된 상태에서
2. https://marketplace.visualstudio.com/items?itemName=ms-vscode.vs-keybindings keymap 파일 설치
vscode terminal 에 conda를 연결하자 (0) | 2022.07.06 |
---|---|
vscode에 conda 가상환경을 연결하자. (0) | 2022.07.06 |
골뱅이 연산자의 의미 (행렬곱). (0) | 2022.05.09 |
예쁘게 출력하자 pprint - pretty print (0) | 2022.03.16 |
이미지 실제 파일 포맷 확인하기 (0) | 2022.02.07 |
이전에 파이썬에서 쓰이는 골뱅이는 데코레이터의 역할로 확인했었고 그것만 기억하고 있었다.
이후 코드를 보다 중간에 골뱅이가 쓰인것을 보고 찾아본 다른 사용법.
@ 연산자는 numpy에서 matmul 또는 dot와 같은 역할을 한다.
즉, 행렬곱을 계산하는 연산자이다.
asterisk로 표현되는 element-wise 곱 연산이 아닌 행렬-행렬간 곱을 계산할때 사용한다.
vscode에 conda 가상환경을 연결하자. (0) | 2022.07.06 |
---|---|
vscode keymap을 변경하자 (0) | 2022.07.06 |
예쁘게 출력하자 pprint - pretty print (0) | 2022.03.16 |
이미지 실제 파일 포맷 확인하기 (0) | 2022.02.07 |
warning 을 on/off 하자 (0) | 2022.01.20 |
프린터를 사용하다 보면 용지가 충분한데도 용지없음 상태로 인쇄가 불가능 할 때가 있다
이럴 경우 해결을 위해 메모
1. 컴퓨터관리 - 서비스 및 응용프로그램 - 서비스 - Print Spooler
2. 서비스 중지 - 재시작
위 과정을 통해 프린터 상태를 업데이트 할 수 있고 이후 정상적으로 출력이 가능 해 진다.
windows 11 작업표시줄 시계 크기 오류를 해결하자 (0) | 2022.10.05 |
---|---|
windows 11 작업표시줄 크기를 변경하자 (0) | 2022.10.05 |
작업표시줄 미리보기를 리스트로 변경하자 (0) | 2022.02.07 |
창 흔들어 최소화 기능 끄기 (0) | 2021.01.27 |
CMD의 테마를 바꿔보자 (콘솔 색 구성 변경) (0) | 2020.08.11 |
MXNet 프레임워크에서는 RecordIO 를 이용하여 학습에 사용되는 데이터의 리스트를 만들고
해당파일을 rec파일로 만들어서 학습에 사용한다
단순히 이미지를 순차적으로 읽어 오는 경우에 비해 학습에 걸리는 시간이 유의미하게 차이나기 때문에
필요한 경우 rec파일로 만들어서 사용하면 도움이 될 수 있다.
파일 변환에는 im2rec.py 파일을 이용하고 해당 파일은 공식 github에서 받을 수 있다.
https://github.com/apache/incubator-mxnet/blob/master/tools/im2rec.py
[make list]
사용법 : python im2rec.py [outputpath/title] [DBPATH] --recursive --list --num-thread 8
예시 : python im2rec.py ./output/output /home/user/database/train --recursive --list --num-thread 8
[make rec - train]
사용법 : python im2rec.py [outputpath/] [DBPath] --recursive --pass-through --pack-label --num-thread 8
예시 : python im2rec.py ./output/ /home/user/database/train --recursive --pass-through --pack-label --num-thread 8
[make rec - test]
사용법 : python im2rec.py [outputpath/] [DBPath] --recursive --pass-through --pack-label --no-shuffle --num-thread 8
[Pytorch] DDP 환경에서 load_state_dict 사용시 OOM 발생 상황을 해결하자 (0) | 2023.06.08 |
---|---|
[Pytorch] Boolean value of Tensor with more than one value is ambiguous 에러를 해결하자. (0) | 2023.06.07 |
[Pytorch] pycharm 환경에서 torch.distributed.launch를 실행하자 (1) | 2021.07.13 |
[Tensorflow] h5py 관련 오류를 해결하자 (0) | 2021.04.26 |
[ONNX] cuda 버전에 따른 python onnxruntime 버전을 맞추자. (0) | 2021.03.09 |
딕셔너리, json 등을 print로 찍어 볼 일이 가끔 있는데
이런 데이터들은 그냥 print로 출력하면 정보가 구분없이 한주롤 쭉 나와서 가독성이 크게 떨어진다
이럴 때 사용가능한 예쁜 출력 - pretty print -> pprint!
사용법은 매우 심플하게
pprint 모듈의 pprint를 import 해 준 뒤 print 대신 pprint를 사용하면 된다
from pprint import pprint
data = {~~~~블라블라~~~}
# 기존 출력
print(data)
# 예쁘게 출력
pprint(data)
vscode keymap을 변경하자 (0) | 2022.07.06 |
---|---|
골뱅이 연산자의 의미 (행렬곱). (0) | 2022.05.09 |
이미지 실제 파일 포맷 확인하기 (0) | 2022.02.07 |
warning 을 on/off 하자 (0) | 2022.01.20 |
python version에 따른 pickle 버전 정리 (0) | 2021.10.06 |
작업표시줄에 있는 프로그램이 몇개 되지 않을때는 마우스를 올리면 미리보기 화면이 뜨게 된다
개인적으로는 이 미리보기 화면이 크기도 작아서 눈에 잘 들어오지도 않을 뿐더러
코딩을 위한 IDE를 여러개 띄운 경우에는 미리보기 화면은 의미가 없다
차라리 리스트 형태로 타이틀 정보가 더 길게 나오는게 편한 경우가 많더라
그래서 프로그램이 몇개 떠 있지 않은 경우에도 리스트로 출력되도록 변경 해 보자
1. 레지스트리 편집기 실행 (윈도우+R -> regedit)
2. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband 로 이동
3. 새로만들기 -> DWROD 값 (이름 : NumThumbnails / 값 : 0 (dex))
4. reboot
재부팅 후 창들이 리스트 형태로 출력됨을 확인할 수 있다.
windows 11 작업표시줄 크기를 변경하자 (0) | 2022.10.05 |
---|---|
프린터 용지 부족 문제를 해결하자 (0) | 2022.04.11 |
창 흔들어 최소화 기능 끄기 (0) | 2021.01.27 |
CMD의 테마를 바꿔보자 (콘솔 색 구성 변경) (0) | 2020.08.11 |
엑셀 작업 중 프리징을 해결하자 (0) | 2020.02.07 |
이미지 파일을 사용하다 보면 파일명의 확장자와 실제 이미지의 포맷이 다른 경우가 가끔 있다.
이런 파일을 확인하기 위한 방법 정리.
파이썬의 PIL-Image 모듈을 이용하면 쉽게 실제 포맷을 확인 할 수 있다.
from PIL import Image
img = Image.open("sample01.jpg")
img.format
>> 'GIF'
# 이 경우 파일명 확장자는 jpg 이나 실제 이미지 포맷은 gif인 경우.
실제 정보를 확인 한 후 적절한 처리를 하고 사용하면 된다.
골뱅이 연산자의 의미 (행렬곱). (0) | 2022.05.09 |
---|---|
예쁘게 출력하자 pprint - pretty print (0) | 2022.03.16 |
warning 을 on/off 하자 (0) | 2022.01.20 |
python version에 따른 pickle 버전 정리 (0) | 2021.10.06 |
pycharm 에서 인덱싱 제외 폴더를 설정하자 (0) | 2021.08.06 |
국내 택배와 달리 해외에서 배송되는 물건의 운송상태는 업데이트가 잘 되지 않거나
업데이트가 되더라도 두루뭉술하게 큰 범주의 상태만 표시되는 경우가 왕왕있다.
송장번호를 알고있다면 아래와 같이 세부사항을 조회 가능하다.
(추가로 알리의 경우 주문번호가 아닌 배송추적 페이지의 하단에 배송방법 탭에 있는 숫자가 송장번호이다.)
1. 국가관세종합정보망 사이트 접속 (https://unipass.customs.go.kr/csp/index.do)
2. 화물진행정보 에서 "M B/L - H B/L" 선택
3. 운송장번호에 알고있는 운송장 번호 입력
4. 조회.
KAWASAKI Z900 신차 구매기 / 알리제품 구매후기 (2) | 2018.09.12 |
---|---|
알리익스프레스 배송 상태 정리 (1) | 2018.09.03 |
블루투스 비모토v6 v8 사용법 정리 (1) | 2018.02.14 |
[DSLR] 한해의 끝에서 그나마 맘에드는 기록들. (0) | 2014.12.20 |
[DSLR] 첫 렌즈구매 EF 40mm f/2.8 STM (0) | 2014.08.07 |
티스토리 코드블럭에 작성된 내용을 복사하여 다른곳에 붙여넣으면
한줄로 쭉 이어져버리는 문제가 있었다.
이 경우는 플러그인 중 "저작권자 표시" 기능이 활성화 되어 있을 경우 발생하는 문제로
꼭 필요한 것이 아니라면 "저작권자 표시" 기능을 해제하면 문제가 해결된다.
글목록의 상단에 광고를 추가 해 보자. (0) | 2014.12.10 |
---|---|
본문내용 상단에 구글 애드센스 광고 두개 나란히 삽입하기. (0) | 2014.12.10 |
[티스토리] TAG에 입체 효과를 주자 - 3D 구름태그 ( CloudTag ) (0) | 2014.01.10 |
Tistory 카테고리 항상 펼쳐보기 (0) | 2014.01.10 |
외부 라이브러리들을 사용하다보면 여러 이유로 warning이 발생하곤 한다
정보 전달을 목적으로 경고를 띄워주는 것이긴 하지만
release 상태에서는 경고 없이 실행한 결과만 보고싶을 때 아래와 같이 경고를 끄는것이 가능하다
import warnings
# warning off
warnings.filterwarnings("ignore")
# warning on
warnings.filterwarnings("default")
예쁘게 출력하자 pprint - pretty print (0) | 2022.03.16 |
---|---|
이미지 실제 파일 포맷 확인하기 (0) | 2022.02.07 |
python version에 따른 pickle 버전 정리 (0) | 2021.10.06 |
pycharm 에서 인덱싱 제외 폴더를 설정하자 (0) | 2021.08.06 |
string 앞에 0 또는 문자를 삽입하여 길이를 맞추자 (0) | 2021.07.02 |
가끔 버그인 것 같긴한데
파일 선택만 되고 드래그&드랍이 안되는 경우가 있다
뭐 재부팅하면야 제대로 동작 하겠지만 매번 그럴수도 없으니 아래 방법을 이용하여 해결하자
1. 파일 우클릭 후 메뉴 뜨면 esc
2. F2 를 눌러 파일 이름 변경 후 esc
둘중에 어떤 조건으로 문제가 해결되는지는 모르겠지만 일단 위 방법으로 문제 해결됨은 확인.
다음번 증상 재현되면 다시 하나씩 해봐야지..
모종의 이유로 guthub 의 repository를 gitlab으로 옮겨야 할 경우가 있다
코드 clone 후 저장소 바꿔서 push 하는 방법도 있겠지만 더 간단한 방법이 있어서 정리
[1단계. github에서]
1. settings - Developer Settings - Personal access tokens
2. scrops 선택(repo 정도로 사용) 후 Generate Token
[2단계. gitlab에서]
1. New project - Import project - Github
2. Personal Access Token에 1의 token 붙여넣기 - List your Github repositories
3. list 중 필요한 repository 우측의 import 로 추가
[WSL2] 경로를 windows 탐색기에서 확인하자. (0) | 2023.08.24 |
---|---|
conda 사용중 "An HTTP error occurred" 가 발생할 경우 (0) | 2022.08.29 |
[ROS] Rosbag2Video (0) | 2021.11.30 |
float 값의 비교 (== 연산자는 위험하다!) (0) | 2021.04.13 |
google drive web client 사용량 제한 (0) | 2021.02.25 |
ROS 에서 녹화된 rosbag 파일 내의 비디오를 추출하는 코드
github에 쓰기 편하게 만들어 준 코드가 있어서 기록.
https://github.com/mlaiacker/rosbag2video
#!/usr/bin/env python3
"""
rosbag2video.py
rosbag to video file conversion tool
by Abel Gabor 2019
baquatelle@gmail.com
requirements:
sudo apt install python3-roslib python3-sensor-msgs python3-opencv ffmpeg
based on the tool by Maximilian Laiacker 2016
post@mlaiacker.de"""
import roslib
#roslib.load_manifest('rosbag')
import rospy
import rosbag
import sys, getopt
import os
from sensor_msgs.msg import CompressedImage
from sensor_msgs.msg import Image
import cv2
import numpy as np
import shlex, subprocess
MJPEG_VIDEO = 1
RAWIMAGE_VIDEO = 2
VIDEO_CONVERTER_TO_USE = "ffmpeg" # or you may want to use "avconv"
def print_help():
print('rosbag2video.py [--fps 25] [--rate 1] [-o outputfile] [-v] [-s] [-t topic] bagfile1 [bagfile2] ...')
print()
print('Converts image sequence(s) in ros bag file(s) to video file(s) with fixed frame rate using',VIDEO_CONVERTER_TO_USE)
print(VIDEO_CONVERTER_TO_USE,'needs to be installed!')
print()
print('--fps Sets FPS value that is passed to',VIDEO_CONVERTER_TO_USE)
print(' Default is 25.')
print('-h Displays this help.')
print('--ofile (-o) sets output file name.')
print(' If no output file name (-o) is given the filename \'<prefix><topic>.mp4\' is used and default output codec is h264.')
print(' Multiple image topics are supported only when -o option is _not_ used.')
print(' ',VIDEO_CONVERTER_TO_USE,' will guess the format according to given extension.')
print(' Compressed and raw image messages are supported with mono8 and bgr8/rgb8/bggr8/rggb8 formats.')
print('--rate (-r) You may slow down or speed up the video.')
print(' Default is 1.0, that keeps the original speed.')
print('-s Shows each and every image extracted from the rosbag file (cv_bride is needed).')
print('--topic (-t) Only the images from topic "topic" are used for the video output.')
print('-v Verbose messages are displayed.')
print('--prefix (-p) set a output file name prefix othervise \'bagfile1\' is used (if -o is not set).')
print('--start Optional start time in seconds.')
print('--end Optional end time in seconds.')
class RosVideoWriter():
def __init__(self, fps=25.0, rate=1.0, topic="", output_filename ="", display= False, verbose = False, start = rospy.Time(0), end = rospy.Time(sys.maxsize)):
self.opt_topic = topic
self.opt_out_file = output_filename
self.opt_verbose = verbose
self.opt_display_images = display
self.opt_start = start
self.opt_end = end
self.rate = rate
self.fps = fps
self.opt_prefix= None
self.t_first={}
self.t_file={}
self.t_video={}
self.p_avconv = {}
def parseArgs(self, args):
opts, opt_files = getopt.getopt(args,"hsvr:o:t:p:",["fps=","rate=","ofile=","topic=","start=","end=","prefix="])
for opt, arg in opts:
if opt == '-h':
print_help()
sys.exit(0)
elif opt == '-s':
self.opt_display_images = True
elif opt == '-v':
self.opt_verbose = True
elif opt in ("--fps"):
self.fps = float(arg)
elif opt in ("-r", "--rate"):
self.rate = float(arg)
elif opt in ("-o", "--ofile"):
self.opt_out_file = arg
elif opt in ("-t", "--topic"):
self.opt_topic = arg
elif opt in ("-p", "--prefix"):
self.opt_prefix = arg
elif opt in ("--start"):
self.opt_start = rospy.Time(int(arg))
if(self.opt_verbose):
print("starting at",self.opt_start.to_sec())
elif opt in ("--end"):
self.opt_end = rospy.Time(int(arg))
if(self.opt_verbose):
print("ending at",self.opt_end.to_sec())
else:
print("opz:", opt,'arg:', arg)
if (self.fps<=0):
print("invalid fps", self.fps)
self.fps = 1
if (self.rate<=0):
print("invalid rate", self.rate)
self.rate = 1
if(self.opt_verbose):
print("using ",self.fps," FPS")
return opt_files
# filter messages using type or only the opic we whant from the 'topic' argument
def filter_image_msgs(self, topic, datatype, md5sum, msg_def, header):
if(datatype=="sensor_msgs/CompressedImage"):
if (self.opt_topic != "" and self.opt_topic == topic) or self.opt_topic == "":
print("############# COMPRESSED IMAGE ######################")
print(topic,' with datatype:', str(datatype))
print()
return True;
if(datatype=="theora_image_transport/Packet"):
if (self.opt_topic != "" and self.opt_topic == topic) or self.opt_topic == "":
print(topic,' with datatype:', str(datatype))
print('!!! theora is not supported, sorry !!!')
return False;
if(datatype=="sensor_msgs/Image"):
if (self.opt_topic != "" and self.opt_topic == topic) or self.opt_topic == "":
print("############# UNCOMPRESSED IMAGE ######################")
print(topic,' with datatype:', str(datatype))
print()
return True;
return False;
def write_output_video(self, msg, topic, t, video_fmt, pix_fmt = ""):
# no data in this topic
if len(msg.data) == 0 :
return
# initiate data for this topic
if not topic in self.t_first :
self.t_first[topic] = t # timestamp of first image for this topic
self.t_video[topic] = 0
self.t_file[topic] = 0
# if multiple streams of images will start at different times the resulting video files will not be in sync
# current offset time we are in the bag file
self.t_file[topic] = (t-self.t_first[topic]).to_sec()
# fill video file up with images until we reache the current offset from the beginning of the bag file
while self.t_video[topic] < self.t_file[topic]/self.rate :
if not topic in self.p_avconv:
# we have to start a new process for this topic
if self.opt_verbose :
print("Initializing pipe for topic", topic, "at time", t.to_sec())
if self.opt_out_file=="":
out_file = self.opt_prefix + str(topic).replace("/", "_")+".mp4"
else:
out_file = self.opt_out_file
if self.opt_verbose :
print("Using output file ", out_file, " for topic ", topic, ".")
if video_fmt == MJPEG_VIDEO :
cmd = [VIDEO_CONVERTER_TO_USE, '-v', '1', '-stats', '-r',str(self.fps),'-c','mjpeg','-f','mjpeg','-i','-','-an',out_file]
self.p_avconv[topic] = subprocess.Popen(cmd, stdin=subprocess.PIPE)
if self.opt_verbose :
print("Using command line:")
print(cmd)
elif video_fmt == RAWIMAGE_VIDEO :
size = str(msg.width)+"x"+str(msg.height)
cmd = [VIDEO_CONVERTER_TO_USE, '-v', '1', '-stats','-r',str(self.fps),'-f','rawvideo','-s',size,'-pix_fmt', pix_fmt,'-i','-','-an',out_file]
self.p_avconv[topic] = subprocess.Popen(cmd, stdin=subprocess.PIPE)
if self.opt_verbose :
print("Using command line:")
print(cmd)
else :
print("Script error, unknown value for argument video_fmt in function write_output_video.")
exit(1)
# send data to ffmpeg process pipe
self.p_avconv[topic].stdin.write(msg.data)
# next frame time
self.t_video[topic] += 1.0/self.fps
def addBag(self, filename):
if self.opt_display_images:
from cv_bridge import CvBridge, CvBridgeError
bridge = CvBridge()
cv_image = []
if self.opt_verbose :
print("Bagfile: {}".format(filename))
if not self.opt_prefix:
# create the output in the same folder and name as the bag file minu '.bag'
self.opt_prefix = bagfile[:-4]
#Go through the bag file
bag = rosbag.Bag(filename)
if self.opt_verbose :
print("Bag opened.")
# loop over all topics
for topic, msg, t in bag.read_messages(connection_filter=self.filter_image_msgs, start_time=self.opt_start, end_time=self.opt_end):
try:
if msg.format.find("jpeg")!=-1 :
if msg.format.find("8")!=-1 and (msg.format.find("rgb")!=-1 or msg.format.find("bgr")!=-1 or msg.format.find("bgra")!=-1 ):
if self.opt_display_images:
np_arr = np.fromstring(msg.data, np.uint8)
cv_image = cv2.imdecode(np_arr, cv2.CV_LOAD_IMAGE_COLOR)
self.write_output_video( msg, topic, t, MJPEG_VIDEO )
elif msg.format.find("mono8")!=-1 :
if self.opt_display_images:
np_arr = np.fromstring(msg.data, np.uint8)
cv_image = cv2.imdecode(np_arr, cv2.CV_LOAD_IMAGE_COLOR)
self.write_output_video( msg, topic, t, MJPEG_VIDEO )
elif msg.format.find("16UC1")!=-1 :
if self.opt_display_images:
np_arr = np.fromstring(msg.data, np.uint16)
cv_image = cv2.imdecode(np_arr, cv2.CV_LOAD_IMAGE_COLOR)
self.write_output_video( msg, topic, t, MJPEG_VIDEO )
else:
print('unsupported jpeg format:', msg.format, '.', topic)
# has no attribute 'format'
except AttributeError:
try:
pix_fmt=None
if msg.encoding.find("mono8")!=-1 or msg.encoding.find("8UC1")!=-1:
pix_fmt = "gray"
if self.opt_display_images:
cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
elif msg.encoding.find("bgra")!=-1 :
pix_fmt = "bgra"
if self.opt_display_images:
cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
elif msg.encoding.find("bgr8")!=-1 :
pix_fmt = "bgr24"
if self.opt_display_images:
cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
elif msg.encoding.find("bggr8")!=-1 :
pix_fmt = "bayer_bggr8"
if self.opt_display_images:
cv_image = bridge.imgmsg_to_cv2(msg, "bayer_bggr8")
elif msg.encoding.find("rggb8")!=-1 :
pix_fmt = "bayer_rggb8"
if self.opt_display_images:
cv_image = bridge.imgmsg_to_cv2(msg, "bayer_rggb8")
elif msg.encoding.find("rgb8")!=-1 :
pix_fmt = "rgb24"
if self.opt_display_images:
cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
elif msg.encoding.find("16UC1")!=-1 :
pix_fmt = "gray16le"
else:
print('unsupported encoding:', msg.encoding, topic)
#exit(1)
if pix_fmt:
self.write_output_video( msg, topic, t, RAWIMAGE_VIDEO, pix_fmt )
except AttributeError:
# maybe theora packet
# theora not supported
if self.opt_verbose :
print("Could not handle this format. Maybe thoera packet? theora is not supported.")
pass
if self.opt_display_images:
cv2.imshow(topic, cv_image)
key=cv2.waitKey(1)
if key==1048603:
exit(1)
if self.p_avconv == {}:
print("No image topics found in bag:", filename)
bag.close()
if __name__ == '__main__':
#print()
#print('rosbag2video, by Maximilian Laiacker 2020 and Abel Gabor 2019')
#print()
if len(sys.argv) < 2:
print('Please specify ros bag file(s)!')
print_help()
sys.exit(1)
else :
videowriter = RosVideoWriter()
try:
opt_files = videowriter.parseArgs(sys.argv[1:])
except getopt.GetoptError:
print_help()
sys.exit(2)
# loop over all files
for files in range(0,len(opt_files)):
#First arg is the bag to look at
bagfile = opt_files[files]
videowriter.addBag(bagfile)
print("finished")
conda 사용중 "An HTTP error occurred" 가 발생할 경우 (0) | 2022.08.29 |
---|---|
[Git] github -> gitlab / repository를 이사하자 (0) | 2021.12.06 |
float 값의 비교 (== 연산자는 위험하다!) (0) | 2021.04.13 |
google drive web client 사용량 제한 (0) | 2021.02.25 |
pycharm 사용 및 환경설정 팁 (0) | 2019.03.18 |
pickle 데이터를 load 할 때 가끔 unsupport protocol 에러를 보는 경우가 있다.
이 경우 dump 한 버전과 load 한 버전이 달라서 발생하는 문제.
기본 버전을 확인하기 위해 기록
python ver. | pickle protocol ver. |
1.x | 1 |
2.3~2.7 | 2 |
3.0~3.7 | 3 |
3.8 | 4 |
3.8 | 5 |
이미지 실제 파일 포맷 확인하기 (0) | 2022.02.07 |
---|---|
warning 을 on/off 하자 (0) | 2022.01.20 |
pycharm 에서 인덱싱 제외 폴더를 설정하자 (0) | 2021.08.06 |
string 앞에 0 또는 문자를 삽입하여 길이를 맞추자 (0) | 2021.07.02 |
설치된 라이브러리 리스트를 requirements.txt 로 만들자. (0) | 2021.06.18 |