Skip to content

Margus Roo –

If you're inventing and pioneering, you have to be willing to be misunderstood for long periods of time

  • Cloudbreak Autoscale fix
  • Endast

iTead Slampher + Sonoff-Tasmota

Posted on June 29, 2017 - June 29, 2017 by margusja

Kuna ma juba mõnda aega nende iTead jubinatega olen toimetanud, siis tekkis tahtmine ka see Slampher ära proovida.

Tellisin iTead lehelt ühe. Üllatavalt ruttu tuli seekord kohale. Alguses proovisin ka tootja enda poolt pakutavat appi, aga mina seda tööle ei saanud. Päris nõme oli ka see, et pidi ennast loomulikult kusagile regama jne.

Olen siiani kasutanud https://github.com/arendst/Sonoff-Tasmota projekti. Uuendasin viimasele versioonile ja kukkusin kompileerima ja uploadima uut firmwaret seadmesse. Tee või tina no ei lähe jubin upload modesse.

 

 

Panin juba jubina kõrvale, et homme tegelen edasi kui siis juhtusin infole, et tuleb tiba joota enne kui omaloomingu peale saab.

Info siin

 

 

Peale R22 kohale silla jootmist läks uus firmware kenasti oma kohale ja seade kenasti võrgus:

Kodune võrk on juba päris huvitav:

Posted in IOT

Jaanipäev 2017

Posted on June 28, 2017 - June 28, 2017 by margusja

Posted in Varia

Ethereum Sol

Posted on June 14, 2017 by margusja

It took me some time to understand Solidity events. But in the end I think I can explain it.

So the example contract:

contract CallCalc {
address calcReg =0xd794EaF737549c2698e2232c07A9b666934584f8;
event TestEvent(address indexed _from , uint);

function call(uint256 input) returns (uint) {
TestEvent(msg.sender, input);
if (!calcReg.call(bytes4(sha3(“add(uint256)”)), input))
throw;
}
}

After executing method call I can see event in my client

 

Posted in Linux

Ethereum JSON_RPC eth_getStorageAt

Posted on June 13, 2017 by margusja

Create a simple contract:


contract Storage {
    uint pos0;
    mapping(address => uint) pos1;
    
    function Storage() {
        pos0 = 1234;
        pos1[msg.sender] = 5678;
    }
}

submit it and get back address. In example 0x9a5CdfCb1132dcbEca55b213372224D9bd0209c2

Now lets execute it under one account. In example 0xa2213890a81042692B4716025D6e98349b432349

Lets see how we can get what is in storage related with contract.

We can use JSON_RPC eth_getStorageAt or web3.eth.getStorageAt from geth command line. In this example I’ll use JSON_RPC eth_getStorageAt.

Contracts storage is basically key-value storage.

To get pos0 is simple:

margusja@IRack:~$ curl -X POST --data '{"jsonrpc":"2.0", "method": "eth_getStorageAt", "params": ["0x9a5CdfCb1132dcbEca55b213372224D9bd0209c2", "0x0", "latest"], "id": 1}' localhost:8545
{"jsonrpc":"2.0","id":1,"result":"0x00000000000000000000000000000000000000000000000000000000000004d2"}

hex value 4d2 to decimal is 1234.

TO get pos1 is more tricky. First we have to calculate index position using contract executor address and index. Go to geth commandline and:

var key = “000000000000000000000000a2213890a81042692B4716025D6e98349b432349″ + “0000000000000000000000000000000000000000000000000000000000000001”

We added zeros to get 64 bit value. Next in geth command line:

web3.sha3(key, {“encoding”: “hex”}) – it returns aadress: 0x790e4fae970c427bd6d93e3f64ba898c69fdead01d68e500efb6f3abc672d632

Now we can get value from storage:

margusja@IRack:~$ curl -X POST --data '{"jsonrpc":"2.0", "method": "eth_getStorageAt", "params": ["0x9a5CdfCb1132dcbEca55b213372224D9bd0209c2", "0x790e4fae970c427bd6d93e3f64ba898c69fdead01d68e500efb6f3abc672d632", "latest"], "id": 1}' localhost:8545
{"jsonrpc":"2.0","id":1,"result":"0x000000000000000000000000000000000000000000000000000000000000162e"}

hex value 162e to decimal is 5678

Source – https://github.com/ethereum/wiki/wiki/JSON-RPC#web3_clientversion

Posted in Linux

Blockchain and Ethereum

Posted on June 8, 2017 by margusja

Fun with ethereum. Build a private network and collecting huge amount ether 🙂

Posted in Linux

Motion detection with OpenCV

Posted on May 23, 2017 by margusja

Olen alati aukartusega vaadanud laenurgas seisvadi automaatseid tulelüliteid, mis liikumise tuvastades lülitavad valguse sisse ja mõne aja pärast taas valguse välja lülitavad. Fantastilised seadmed.

Kuidas nad seda teevad? Variante on mitmeid, ühte neist katsetasin ka ise.

Natukene teooriat – https://en.wikipedia.org/wiki/Background_subtraction

Mina kasutasin OpenCV raamistiku opencv2/video/background_segm.hpp, mis analüüsib videosisendit (pildijada) ja lihtsustatult võttes võrdleb eelmisi pilte praegusega. Liikumise puudumisel on ajalugu suht sarnane. Liikumise olemasolul teatud regioonide ajalugu ei ole sarnane ja antud meetod ka selle siis visualiseerib.

Posted in Machine Learning

Fun with openCV #2

Posted on May 22, 2017 - May 22, 2017 by margusja

Pilt oma olemuselt on lihtsalt kogum teatud formaadis numbreid.

Näiteks allolev pilt (600×338) koosneb 202800 täpist (pixel), kus ühe elemendi väärtus on vahemikus 0…255 (gray scale)

 

 

 

 

 

 

 

 

 

 

 

Arvutis asub pildi info kujul [row1;row2;row3…row600] kus row koosneb 338’t elemendist.

Image =

[143, 138, 139, 139, 143, 140, 142, 142, 143, 141, 141, 143, 145, 145, 144, 143, 143, 149, 150, 147, 147, 150, 151, 151, 151, 151, 151, 152, 154, 154, 152, 149, 153, 151, 152, 154, 155, 154, 153, 154, 159, 158, 157, 157, 156, 156, 156, 156, 156, 157, 157, 154, 153, 154, 157, 159, 158, 155, 156, 157, 157, 157, 158, 158, 155, 157, 159, 159, 157, 156, 157, 160, 163, 159, 160, 162, 159, 159, 161, 159, 161, 163, 163, 164, 165, 166, 166, 165, 165, 167, 168, 167, 165, 163, 163, 164, 164, 162, 161, 161, 162, 163, 163, 162, 161, 164, 164, 163, 165, 170, 169, 166, 168, 168, 166, 167, 167, 166, 168, 166, 166, 163, 162, 165, 167, 168, 167, 167, 166, 167, 168, 168, 166, 166, 168, 170, 167, 166, 167, 148,  91,  57,  56, 143, 168, 169, 161,  78,  17,  42,  34,  35,  30,  24,  21,  22,  24,  23,  22,  23,  21,  28,  29,  27,  26,  27,  30,  28,  24,  27,  28,  26,  27,  29,  28,  25,  29,  27,  27,  27,  26,  25,  26,  25,  27,  20,  19,  23,  20,  23,  24,  28,  27,  31,  34,  34,  35,  34,  32,  31,  32,  27,  27,  29,  31,  30,  28,  25,  21,  23,  22,  27,  23,  21,  21,  23,  25,  27,  27,  23,  20,  21,  23,  23,  23,  27,  20,  22,  23,  18,  23,  24,  27,  16,  30,  40,  33,  38,  10,  61, 154, 122, 137, 145, 146, 130, 130, 133, 130, 125,  94,  86,  99, 108,  96,  98,  95, 105, 100,  82,  66,  62,  61,  61,  73,  79,  72,  66,  73,  77,  68,  57,  44,  47,  70,  87,  77,  59,  55,  63,  57,  55,  58,  46,  52,  57,  56,  57,  64,  62,  62,  82, 113, 117, 119, 127, 116, 114, 113, 111, 105,  49,  34,  50, 136, 156, 156, 163, 164, 160, 158, 153, 158, 164, 166, 163, 161, 162, 160, 158, 153, 150, 146, 139, 138, 133, 119, 114,  75,  17,  33,  30,  63,  67,  69,  72,  72,  73,  67,  65,  59, 144, 159, 156, 156, 156, 159, 147, 125….

52,  54,  57,  57,  55,  60,  86,  90,  98, 111, 115, 112, 100, 103, 106, 119, 141, 158, 159, 158, 157, 158, 159, 161, 164, 172, 178, 180, 177, 176, 181, 185, 184, 183, 177, 160, 140, 135, 134, 135, 145, 151, 149, 147, 142, 143, 144, 160, 179, 183, 173, 178, 186, 186, 187, 188, 189, 183, 178, 181, 182, 180, 181, 179, 176, 174, 172, 170, 171, 171, 170, 172, 169, 174, 173, 179, 181, 182, 187, 182, 174, 169, 166, 162, 161, 164, 166, 169, 172, 174, 176, 179, 180, 168, 157, 160, 165, 176, 174, 106,   0,  22,  19,  18,  20,  11,   4,   5,   6,   4,   3,   2,   2]

Kuna meil on võimalik iga elemendiga omi tehteid teha, siis teeme näiteks lihtsa tehte, kus me muudame kõik elemendid väärtusega 183 väärtuseks 255 (valge):

 

#include
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main(int argc, const char * argv[]) {

Mat image;

image = imread( “image.jpg”, 0 );

int channels = image.channels();
int cols = image.cols;
int rows = image.rows;

cout << “Image = ” << endl << ” ” << image << endl << endl;

cout << “Channels = ” << endl << ” ” << channels << endl << endl;

cout << “Rows = ” << endl << ” ” << rows << endl << endl;
cout << “Cols = ” << endl << ” ” << cols << endl << endl;
cout << “Size = ” << endl << ” ” << image.total() << endl << endl;

for(int i = 0; i < image.rows; i++){
for(int j=0; j < image.cols; j++){
if (image.at(i,j) == 183) {
image.at(i,j) = 255;
}
}
}

// visualize image
namedWindow( “demo”, WINDOW_AUTOSIZE );
imshow( “Demo image”, image );
waitKey(0);

return 0;
}

 

Tulemuseks saame uue pildi:

Posted in Linux

OpenCV-3.2.0 Object tracking

Posted on May 11, 2017 by margusja

 

Object tracking is much more faster than object detecting.
Source from – https://www.learnopencv.com/object-tracking-using-opencv-cpp-python/

Posted in Linux

OpenCV Feature Matching test

Posted on May 10, 2017 - May 10, 2017 by margusja

 

FOUND 7831 keypoints on first image
FOUND 2606 keypoints on second image
SURF run time: 1780.93 ms
Max distance: 0.500609
Min distance: 0.0160885
Calculating homography using 50 point pairs.

 

Source code – https://github.com/opencv/opencv_contrib/blob/master/modules/xfeatures2d/samples/surf_matcher.cpp

Posted in Linux

Playing with OpenCV and OpenCL

Posted on May 8, 2017 by margusja

Posted in Linux

Posts navigation

Older posts
Newer posts

The Master

Categories

  • Apache
  • Apple
  • Assembler
  • Audi
  • BigData
  • BMW
  • C
  • Elektroonika
  • Fun
  • Hadoop
  • help
  • Infotehnoloogia koolis
  • IOT
  • IT
  • IT eetilised
  • Java
  • Langevarjundus
  • Lapsed
  • lastekodu
  • Linux
  • M-401
  • Mac
  • Machine Learning
  • Matemaatika
  • Math
  • MSP430
  • Muusika
  • neo4j
  • openCL
  • Õpetaja identiteet ja tegevusvõimekus
  • oracle
  • PHP
  • PostgreSql
  • ProM
  • R
  • Turvalisus
  • Varia
  • Windows
Proudly powered by WordPress | Theme: micro, developed by DevriX.