Skip to content

Instantly share code, notes, and snippets.

@kjunichi
Created April 30, 2019 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjunichi/2d77703046315de99f1f6bae7bca408b to your computer and use it in GitHub Desktop.
Save kjunichi/2d77703046315de99f1f6bae7bca408b to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"struct M\n",
" A::NTuple{16,Cuchar}\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"mrb =ccall( (:mrb_open, \"mruby\"), Ptr{UInt}, ())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ccall( (:mrb_load_string, \"mruby\"),M,(Ptr{UInt},Cstring),mrb,\"\\$cam=Webcam.new\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ccall( (:mrb_load_string, \"mruby\"),M,(Ptr{UInt},Cstring),mrb,\"\\$cam.capture{|img| \\$img2=img}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ccall( (:mrb_load_string, \"mruby\"),M,(Ptr{UInt},Cstring),mrb,\"\\$cam.snap\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obj = ccall( (:mrb_load_string, \"mruby\"),M,(Ptr{UInt},Cstring),mrb,\"Base64::encode(\\$img2)\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"base64jpeg = ccall( (:mrb_str_to_cstr, \"mruby\"),Cstring,(Ptr{UInt},M),mrb,obj)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"using Base64"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"using Images"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"jpeg=base64decode(unsafe_string(base64jpeg));"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"using ImageMagick"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"img = readblob(jpeg);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"size(img)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"img"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.1.0",
"language": "julia",
"name": "julia-1.1"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.1.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment