This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Retrofit | |
implementation 'com.squareup.retrofit2:retrofit:2.5.0' | |
implementation "com.squareup.retrofit2:converter-moshi:2.5.0" | |
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2" | |
// Moshi | |
implementation "com.squareup.moshi:moshi:1.8.0" | |
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.8.0" | |
// Kotlin Coroutines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://github.com/Unity-Technologies/arfoundation-samples/blob/6296272a416925b56ce85470e0c7bef5c913ec0c/Assets/Scripts/CpuImageSample.cs | |
private static void UpdateRawImage(RawImage rawImage, XRCpuImage cpuImage) | |
{ | |
// Get the texture associated with the UI.RawImage that we wish to display on screen. | |
var texture = rawImage.texture as Texture2D; | |
// If the texture hasn't yet been created, or if its dimensions have changed, (re)create the texture. | |
// Note: Although texture dimensions do not normally change frame-to-frame, they can change in response to | |
// a change in the camera resolution (for camera images) or changes to the quality of the human depth | |
// and human stencil buffers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------ | |
# CALCULATE DISPARITY (DEPTH MAP) | |
# Adapted from: https://github.com/opencv/opencv/blob/master/samples/python/stereo_match.py | |
# and: https://docs.opencv.org/master/dd/d53/tutorial_py_depthmap.html | |
# StereoSGBM Parameter explanations: | |
# https://docs.opencv.org/4.5.0/d2/d85/classcv_1_1StereoSGBM.html | |
# Matched block size. It must be an odd number >=1 . Normally, it should be somewhere in the 3..11 range. | |
block_size = 11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.imshow(disparity_SGBM, cmap='plasma') | |
plt.colorbar() | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Draw the rectified images | |
fig, axes = plt.subplots(1, 2, figsize=(15, 10)) | |
axes[0].imshow(img1_rectified, cmap="gray") | |
axes[1].imshow(img2_rectified, cmap="gray") | |
axes[0].axhline(250) | |
axes[1].axhline(250) | |
axes[0].axhline(450) | |
axes[1].axhline(450) | |
plt.suptitle("Rectified images") | |
plt.savefig("rectified_images.png") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Undistort (rectify) the images and save them | |
# Adapted from: https://stackoverflow.com/a/62607343 | |
img1_rectified = cv.warpPerspective(img1, H1, (w1, h1)) | |
img2_rectified = cv.warpPerspective(img2, H2, (w2, h2)) | |
cv.imwrite("rectified_1.png", img1_rectified) | |
cv.imwrite("rectified_2.png", img2_rectified) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Stereo rectification (uncalibrated variant) | |
# Adapted from: https://stackoverflow.com/a/62607343 | |
h1, w1 = img1.shape | |
h2, w2 = img2.shape | |
_, H1, H2 = cv.stereoRectifyUncalibrated( | |
np.float32(pts1), np.float32(pts2), fundamental_matrix, imgSize=(w1, h1) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Visualize epilines | |
# Adapted from: https://docs.opencv.org/master/da/de9/tutorial_py_epipolar_geometry.html | |
def drawlines(img1src, img2src, lines, pts1src, pts2src): | |
''' img1 - image on which we draw the epilines for the points in img2 | |
lines - corresponding epilines ''' | |
r, c = img1src.shape | |
img1color = cv.cvtColor(img1src, cv.COLOR_GRAY2BGR) | |
img2color = cv.cvtColor(img2src, cv.COLOR_GRAY2BGR) | |
# Edit: use the same random seed so that two images are comparable! | |
np.random.seed(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/', async (req, res) => { | |
// Import database node module | |
const CosmosClientInterface = require("@azure/cosmos").CosmosClient; | |
// Database and container IDs | |
const databaseId = "ToDoList"; | |
const containerId = "Items"; | |
// Configure database access URI and primary key | |
const endpoint = "https://<...>.documents.azure.com:443/"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.andresjakl.partslist | |
import android.util.Log | |
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory | |
import retrofit2.Retrofit | |
import retrofit2.converter.moshi.MoshiConverterFactory | |
// Singleton pattern in Kotlin: https://kotlinlang.org/docs/reference/object-declarations.html#object-declarations | |
object WebAccess { | |
val partsApi : PartsApiClient by lazy { |
NewerOlder