Skip to content

Instantly share code, notes, and snippets.

@amroamroamro
amroamroamro / README.md
Last active January 12, 2024 22:12
[Python] Fitting plane/surface to a set of data points

Python version of the MATLAB code in this Stack Overflow post: https://stackoverflow.com/a/18648210/97160

The example shows how to determine the best-fit plane/surface (1st or higher order polynomial) over a set of three-dimensional points.

Implemented in Python + NumPy + SciPy + matplotlib.

quadratic_surface

@amroamroamro
amroamroamro / README.md
Last active December 25, 2023 20:41
Fourier series animation

MATLAB code to demonstrate [Fourier series][1] representation of periodic signals (as a sum of sinusoidal functions).

The animation shows an approximation of a square wave signal using the first 4-terms of its Fourier series. (Change the parameters near the top of the code to manipulate the animations and explore other variations).

![animation1][6] ![animation2][7]

This was inspired by the following similar animations:

  • [Fourier Series Animation using Circles][2]
@amroamroamro
amroamroamro / README.md
Created July 22, 2015 17:45
[MATLAB] Example MEX-function with CUDA

Example of using CUDA in a MATLAB MEX-function.

Tested on Windows 8.1 x64, MATLAB R2015a, CUDA 6.5, Visual Studio 2013.

Steps to compile and test:

C:\> call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64
C:\> set CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5
C:\> set PATH=%PATH%;%CUDA_PATH%\bin;%CUDA_PATH%\lib;%CUDA_PATH%\lib64
@amroamroamro
amroamroamro / README.md
Created February 1, 2015 19:52
[mexopencv] Epipolar Geometry example
@amroamroamro
amroamroamro / README.md
Last active July 25, 2020 09:31
MEX config files for Microsoft Visual Studio 2017

XML configuration files for compiling MATLAB MEX-files using VS2017. Tested on Windows 10 64-bit with MATLAB R2016b and Visual Studio 2017 (Enterprise Edition), but it should also work with the Community Edition.

  1. First copy the files to MATLABROOT\bin\win64\mexopts (this might trigger a UAC prompt).
  2. Next run mex -setup and mex -setup C++ in MATLAB, and select VS2017 compilers.
  3. Finally test the new settings with a sample MEX-file:
>> mex -v -largeArrayDims test.cpp
@amroamroamro
amroamroamro / mingw.patch
Created February 23, 2018 23:01
MinGW patch for OpenCV 3.4.0
From c68ef0b7e946e4e915f0972a3e5eb6bf6a425f59 Mon Sep 17 00:00:00 2001
From: Amro <amroamroamro@gmail.com>
Date: Fri, 23 Feb 2018 19:20:03 +0200
Subject: [PATCH] fixes for MinGW
* fix mingw detection in cmake file. When test is true, it defines
a macro which instructs DShow header not to use secure string
replacements not found in mingw
* dont pass gcc flags to windres which doesnt understand them
(another workaround is to set ENABLE_PRECOMPILED_HEADERS=OFF)
@amroamroamro
amroamroamro / mingw.patch
Last active November 15, 2017 17:45
MinGW patch for OpenCV 3.3.1
From 90cbdbb555eef10f4418574bc179c5106eece453 Mon Sep 17 00:00:00 2001
From: Amro <amroamroamro@gmail.com>
Date: Wed, 15 Nov 2017 19:13:45 +0200
Subject: [PATCH] fixes for MinGW
* fix generation of pkg-config (libs shouldnt have .dll suffix)
* fix mingw detection in cmake file. When test is true, it defines
a macro which instructs DShow header not to use secure string
replacements not found in mingw
* dont pass gcc flags to windres which doesnt understand them
@amroamroamro
amroamroamro / mingw.patch
Created August 18, 2017 15:54
MinGW patch for OpenCV 3.3.0
From 37163b5ad31d1a7dffa3d4fdf65ce9a357d12054 Mon Sep 17 00:00:00 2001
From: Amro <amroamroamro@gmail.com>
Date: Fri, 18 Aug 2017 16:19:26 +0300
Subject: [PATCH] fixes for MinGW
- add a define before including DShow header,
to not use secure string replacements not defined by mingw
- dont pass gcc flags to windres which doesnt understand them
(another workaround is to set ENABLE_PRECOMPILED_HEADERS=OFF)
@amroamroamro
amroamroamro / README.markdown
Last active October 4, 2017 15:36
[MATLAB R2014b] MEX config files for Intel Parallel Studio XE 2015

XML configuration files for compiling MATLAB MEX-files using Intel Parallel Studio XE 2015. Tested on Windows 8.1 64-bit with MATLAB R2014b, Visual Studio 2013, and Intel Parallel Studio XE 2015.

Here is an example:

>>> mex -f intel_cpp_15_vs2013.xml -v -largeArrayDims test.cpp
>>> test()
@amroamroamro
amroamroamro / README.md
Created November 22, 2016 11:48
[MATLAB] mex locking test

See #299.

Files:

MyClass.m
private/
    MyClass_.cpp

Compile the MEX-file as usual mex -largeArrayDims MyClass_.cpp (preferrably with C++11).