yum install -y xz
1/28/2019
docker command summarise
stop all containers:
docker kill $(docker ps -q)
remove all containers
docker rm $(docker ps -a -q)
remove all docker images
docker rmi $(docker images -q)
access(enter) docker container
docker exec -it docker_container_name sh
Exit from docker container
>exit
Commit container and build image
docker commit container_name image_name
ex) docker commit lambdapack lambda_image
ex) docker commit lambdapack marearts/lambda_image:v1.0.0
Docker build
>docker build --tag hello:0.1 .
>docker build --tag marearts/hello:0.1 .
Docker run shell and tunnelling
>docker run -v $(pwd):/outputs --name nickname -d docker_image tail -f /dev/nullex)
>docker run -v $(pwd):/outputs --name lambdapackgen2 -d marearts/awspy:0.1 tail -f /dev/null
Docker run shell
> docker run -it marearts/amazon_linux_py36:v1.0.0 /bin/bash
>docker exec -i -t container_name /bin/bash /outputs/shfile.sh
ex)
>docker exec -i -t lambdapackgen2 /bin/bash /outputs/buildPack_py3.sh
Restart Docker container
>docker restart <container id or name>
ex)
docker restart 59
it will be updated..
1/27/2019
summarise Azure function docker image deploy
*make python virtualenv
*activate python virtualenv !!
*install azure util cli
https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image#run-the-build-command
make project (app)
func init DocApp100 --docker
change directory
cd DocApp100
new function
func new --name MyHttpTrigger --template "HttpTrigger"
build docker image
docker build --tag marearts/image:v1 .
make new resource group
az group create --name DocGroup --location westeurope
storage account
az storage account create --name docstorage100 --location westeurope --resource-group DocGroup --sku Standard_LRS
create linux service plan
az appservice plan create --name docserviceplan --resource-group DocGroup --sku B1 --is-linux
create app and deploy
az functionapp create --name docapp100 --storage-account docstorage100 --resource-group DocGroup --plan docserviceplan --deployment-container-image-name marearts/image:v1
Configuration the function app
storageConnectionString=$(az storage account show-connection-string --resource-group DocGroup --name docstorage100 --query connectionString --output tsv)
az functionapp config appsettings set --name docapp100 --resource-group DocGroup --settings AzureWebJobsDashboard=$storageConnectionString AzureWebJobsStorage=$storageConnectionString
Test
curl https://docapp100.azurewebsites.net/api/MyHttpTrigger?name=myname
Azure function create command summarise.
reference:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#v2
https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python
create project
func init PythonAzure
create azure function
func new
Test
func host test
create resource group
az group create --name mareartstest --location westeurope
create strage account
az storage account create --name mareartsteststorage --location westeurope --resource-group mareartstest --sku Standard_LRS
create app
az functionapp create --resource-group mareartstest --os-type Linux --consumption-plan-location westeurope --runtime python --name mareartstest --storage-account mareartsteststorage
deploy
func azure functionapp publish mareartstest
1/23/2019
python "argparse" simple usage
If you use "argparse" lib, you can get the argument parameters very easily in python.
Let's look below code.
test1.py
import argparse
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
#param add
ap.add_argument("-z", "--zip", type=int, required=True, help="input zip code")
#param add
ap.add_argument("-n", "--name", type=str, required=True, help="input your name")
#get param
args = ap.parse_args()
print(args.zip)
print(args.name)
print('---------')
#get param
args = vars(ap.parse_args())
print(args["zip"])
print(args["name"])
The code accepts 2 arguments those are 'zip' and 'name'
So how to input argument?
See the several example
>python test1.py -z 1234 -n kjh
1234
kjh
---------
1234
kjh
>python test1.py
usage: test1.py [-h] -z ZIP -n NAME
test1.py: error: the following arguments are required: -z/--zip, -n/--name
>python test1.py -h
usage: test1.py [-h] -z ZIP -n NAME
optional arguments:
-h, --help show this help message and exit
-z ZIP, --zip ZIP input zip code
-n NAME, --name NAME input your name
you can send argument param
-z or --zip for zip code
-n or --name for name string
Thank you.
reference : https://docs.python.org/3/library/argparse.html
1/10/2019
pipenv command summarising.
referenced from :
https://realpython.com/pipenv-guide/ (english)
install
$ pip install pipenv
$ brew install pipenv
make virtualenv
$ mkdir myenv
$ cd myenv
$ pipenv --python 3.6
install requirements pipenv
$ cd my_project
$ pipenv install
pipenv package install & uninstall
$ pipenv install beautifulsoup4
$ pipenv uninstall beautifulsoup4
freeze → pip freeze > "requirements.txt"
$ pipenv lock
install package to development version
$ pipenv install --dev pytest
install development version requirements
install development version requirements
$ pipenv install --dev
activate pipenv virtualenv
$ pipenv shell
deactivate pipenv virtualenv
$ exit
run pipenv without activate
$ pipenv run which python
$ pipenv run python my_project.py
12/09/2018
Table(grid) detector
Table(grid) detector source code.
The code find table row & col lines in document image.
Output
Table(Grid) Detector
buy : https://www.cvlecture.marearts.com/product-page/table-grid-detector
test : http://www.marearts.com/webapp/dtable/
github : https://github.com/MareArts/DTable
Usage source code
#include "DTable.h" //for local computer void main() { CDTable cDT; //test image char str[255]; for (int i = 0; i < 10; ++i) { //make file string sprintf_s(str, "%d.jpg", i + 1); printf("%s open \n", str); //read Mat oimg = imread(str); //check if (oimg.empty()) continue; //get rect vector vector< GridV> vRect; //dtable if (cDT.FindGrid(oimg, vRect, 0, 0) == false) { printf("Couldn't Find \n"); break; } //show table namedWindow("oimg", 0); int idx = 0; for (auto it : vRect) { printf("%d grid : (x:%d, y:%d, width:%d, height:%d \n", idx, it.rect.x, it.rect.y, it.rect.width, it.rect.height); if (it.pure) cv::rectangle(oimg, it.rect, CV_RGB(0, 255, 0), 2); else cv::rectangle(oimg, it.rect, CV_RGB(255, 0, 0), 2); idx++; } vRect.clear(); //exit imshow("oimg", oimg); if (waitKey(0) == 'q') { break; } } destroyAllWindows(); }
Subscribe to:
Posts (Atom)
-
This is data acquisition source code of LMS511(SICK co.) Source code is made by MFC(vs 2008). The sensor is communicated by TCP/IP. ...
-
Created Date : 2011.2 Language : C/C++ Tool : Microsoft Visual C++ 2010 Library & Utilized : OpenCV 2.2 Reference : Interent Refer...
-
Background subtractor example souce code. OpenCV support about 3 types subtraction algorithm. Those are MOG, MOG2, GMG algorithms. Det...
-
This post is about how to copy Mat data to vector and copy vector data to Mat. Reference this example source code. printf ( "/////...
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
-
EMD(earth mover distance) method is very good method to compare image similarity. But processing time is slow. For using the EMD compare, ...
-
This example source code is to extract HOG feature from images. And save descriptors to XML file. The source code explain how to use HOGD...
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
I use MOG2 algorithm to background subtraction. The process is resize to small for more fast processing to blur for avoid noise affectio...
-
* Introduction - The solution shows panorama image from multi images. The panorama images is processing by real-time stitching algorithm...