Skip to content

Instantly share code, notes, and snippets.

💭

El Bruno elbruno

💭
Block or report user

Report or block elbruno

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@elbruno
elbruno / CsvToJsonforCSAnomalyDetector.cs
Created Nov 24, 2019
CsvToJsonforCSAnomalyDetector.cs
View CsvToJsonforCSAnomalyDetector.cs
static string CsvToJson(string csvPath, string granularity = "daily", bool hasHeaders = true)
{
char[] fieldSeparator = { ',' };
var lines = System.IO.File.ReadAllLines(csvPath);
// remove header
if (hasHeaders)
lines = lines.Skip(1).ToArray();
// build series
@elbruno
elbruno / UninstallDotNetCoreVersions.ps1
Created Oct 15, 2019
UninstallDotNetCoreVersions.ps1
View UninstallDotNetCoreVersions.ps1
# get installed dotNet SDKs
$dnSDKs = dotnet --list-sdks
Write-Host "---------------------------"
Write-Host "Installed SDKs:"
foreach ($dnSDK in $dnSDKs) {
Write-Host $dnSDK
}
Write-Host "---------------------------"
@elbruno
elbruno / CustomVisionEstimationSampleUsage.cs
Created Oct 9, 2019
CustomVisionEstimationSampleUsage.cs
View CustomVisionEstimationSampleUsage.cs
// open file as byte array
var byteData = GetImageAsByteArray(imageFilePath);
// prediction
var client = new HttpClient();
using var content = new ByteArrayContent(byteData);
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
var response = await client.PostAsync(Url, content);
var jsonResponse = await response.Content.ReadAsStringAsync();
@elbruno
elbruno / CustomVisionEstimation.cs
Created Oct 9, 2019
CustomVisionEstimation.cs
View CustomVisionEstimation.cs
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
// created with https://app.quicktype.io/#l=cs&r=
namespace DistractedDriverDetectionShared
{
public partial class CustomVisionEstimation
View PythonWebCamFeed.py
import os
import cv2
import time
# init camera
execution_path = os.getcwd()
camera = cv2.VideoCapture(0)
while True:
# Init and FPS process
@elbruno
elbruno / AzureIoTCSendDeviceProperty.py
Created Sep 23, 2019
AzureIoTCSendDeviceProperty.py
View AzureIoTCSendDeviceProperty.py
import os
import iotc
def getCPUtemperature():
res = os.popen('vcgencmd measure_temp').readline()
return(res.replace("temp=","").replace("'C\n",""))
def sendTempAndConnectionDate():
print("Sending temp and connection date ..")
propJson = "{\"rpiTemp\": \"" + str(getCPUtemperature()) + "\"}"
@elbruno
elbruno / RaspberryPiGetDeviceTemp.py
Created Sep 23, 2019
RaspberryPiGetDeviceTemp.py
View RaspberryPiGetDeviceTemp.py
import os
def getCPUtemperature():
res = os.popen('vcgencmd measure_temp').readline()
return(res.replace("temp=","").replace("'C\n",""))
print(getCPUtemperature())
@elbruno
elbruno / AzureIoTCSendCustomTelemetryAndEvent.py
Created Sep 17, 2019
AzureIoTCSendCustomTelemetryAndEvent.py
View AzureIoTCSendCustomTelemetryAndEvent.py
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license.
# Based on
# https://raw.githubusercontent.com/Azure/iot-central-firmware/master/RaspberryPi/app.py
...
while iotc.isConnected():
iotc.doNext() # do the async work needed to be done for MQTT
if gCanSend == True:
@elbruno
elbruno / AzureIoTCSendCustomTelemetry.py
Created Sep 17, 2019
AzureIoTCSendCustomTelemetry.py
View AzureIoTCSendCustomTelemetry.py
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license.
# Based on
# https://raw.githubusercontent.com/Azure/iot-central-firmware/master/RaspberryPi/app.py
...
while iotc.isConnected():
iotc.doNext() # do the async work needed to be done for MQTT
if gCanSend == True:
@elbruno
elbruno / ImageAIRealTimeWebCamPerformance.py
Created Aug 11, 2019
ImageAIRealTimeWebCamPerformance.py
View ImageAIRealTimeWebCamPerformance.py
# load HL detection model from imageAI
# open camera with openCV, analyze frame by frame
# draw a red frame around the detected object
# display FPS, resize image to 1/4 to improve performance
from imageai.Detection.Custom import CustomObjectDetection
import os
import cv2
import time
You can’t perform that action at this time.