12/15/2022

python example split string only using re (regular expression)

 refer to code 


..

import re
target_string = "TOIMITUSKULJETTAJA Työpaikka Contracting & Procurement (REMOTE)12 45 78 Kuljetusauto (RAC.Transporter Car..Operations.Nonex) Työpaikka Dallasiss"
# split on white-space
word_list = re.split(r'[`\-=~!@#$%^&*()_+\[\]{};\'\\:"|<,./<>? ]', target_string)
#remove '' str
word_list = [i for i in word_list if i]
print(word_list, type(word_list))

..

output

['TOIMITUSKULJETTAJA', 'Työpaikka', 'Contracting', 'Procurement', 'REMOTE', '12', '45', '78', 'Kuljetusauto', 'RAC', 'Transporter', 'Car', 'Operations', 'Nonex', 'Työpaikka', 'Dallasiss'] <class 'list'>


Thank you.
🙇🏻‍♂️
www.marearts.com


12/13/2022

search all certain files recursively including subfolder - python example

 

refer to code

..

from pathlib import Path
mypath = "folder1/folder2"
for path in Path(annotation_addr).rglob('*.json'):
print(path) #full path
print(path.name) #file name

..


Thank you.

www.marearts.com

🙇🏻‍♂️

12/12/2022

opencv c++ resizeWindow example

 Original image size [5120x2188], but you can imshow as 300x300 and resizable.

..

#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"  
#include <iostream>
#include <chrono>
 
#pragma comment(lib, "opencv_highgui453.lib")
#pragma comment(lib, "opencv_imgcodecs453.lib")
#pragma comment(lib, "opencv_core453.lib")
 
int main() {
	//read image
	cv::Mat oImg = cv::imread("Resized_Blackpink_PUBG_210321.jpg");
	cv::namedWindow("oimg", cv::WINDOW_NORMAL);
	cv::resizeWindow("oimg", 300, 300);
	cv::imshow("oimg", oImg);
	cv::waitKey(0);
}

..


Thank you.