cpp

Creating Javascript accessible object from C++ / CEF

Example with Chromium Embedded Framework (CEF) on how to create an object in C++ and make it accessible via Javascript. console.inof(api) Object {ready: true, version: "psql.0.0.1", info: Object, getVersion: function}console.inof(api) Object {ready: true, version: "psql.0.0.1", info: Object, getVersion: function} void ExtractEngineApp::OnContextCreated( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) {   auto info = CefV8Value::CreateObject(NULL, NULL); info->SetValue("major", …

Creating Javascript accessible object from C++ / CEF Read More »

Population Count using popcnt instruction (counting number of on bits)

Using popcnt instruction found on newer processors to get population count which is number of set bits. Reference : SSE4 Here are couple example inputs with expected output. 0xA = 1010 — > 2 0x3F2 = 1111110010 — > 7 #include <iostream> #include <stdio.h>   using namespace std;   int main() { // 0xA = …

Population Count using popcnt instruction (counting number of on bits) Read More »

Leptonica Tutorial – Cropping

Common use is to crop to certain area of an image, this can be quite easily accomplished with following code. BOX* box = boxCreate(x, y, w, h); PIX* dpix= pixClipRectangle(spix, box, NULL);BOX* box = boxCreate(x, y, w, h); PIX* dpix= pixClipRectangle(spix, box, NULL);