Friday, November 20, 2020

Rotating a point using Quaternions

 The RealSense tracking camera T265 outputs rotation as a quaternion, and translation as a vector.

 This is all the background needed to understand point rotation using quaternions   p' = qpq'

Format of a quaternion q:

The quaternion format displayed is [x,y,z,w], where x,y,z is the vector portion and w is the scalar.

For clarity, lets use this notation to talk about quaternions [qw, qx, qy, qz]. 

Where the realsense quaternion output is just re-ordered and re-labeled.  w is now qw, x is now qx, y is now qy and z is now qz.

qw contains the information about the amount of rotation around the axis contained in qx, qy, qz.

BUT THIS IS IMPORTANT:  

qx, qy, qz is not directly the vector of rotation.

qw = cos( angle of rotation / 2)

qx = sin( angle of rotation / 2)  * the x component of the vector of rotation.

qy = sin( angle of rotation / 2)  * the y component of the vector of rotation.

qz = sin( angle of rotation / 2)  * the z component of the vector of rotation.

Finding Angle of rotation and axis of rotation vector

If you want to find the angle of rotation around the axis vector calculate the arccosine of qw and multiply by 2:

angle of rotation =  2 * (arccos (qw))  

To find the vector that is the axis of rotation qx, qy, and qz must be divided by the sin(angle of rotation/2)

axis vector x component = qx /  sin( angle of rotation / 2)

axis vector y component = qy /  sin( angle of rotation / 2)

axis vector z component = qz /  sin( angle of rotation / 2)


Conjugate quaternion q'

 Rotating the same angle around the opposite vector reverses the rotation.  The vector is simply multiplied by -1.  This is considered the conjugate because the sign of the axis vector components are all reversed.  The conjugate quaternion is needed to flip the quaternion frame of reference when a quaternion is used to rotate a point in space.  The angle of rotation does not change, only the vector is inverted.

To create a conjugate quaternion do the following

qw' = conjugate qw = qw = cos( angle of rotation / 2)

qx' = conjugate qx =  -1 * sin( angle of rotation / 2)  * the x component of the vector of rotation.

qy' = conjugate qy =  -1 * sin( angle of rotation / 2)  * the y component of the vector of rotation.

qz' = conjugate qz =  -1 * sin( angle of rotation / 2)  * the z component of the vector of rotation.


Convert the point to a quaternion  p

 A point can be represented as a vector.  We will use px, py, pz as our point notation.  To create a quaternion from the point just add pw with a value of zero.  But remember that has to be equal to the cosine of the rotation divided by 2.  The arccos(0) = 90 degrees. Multiplied by 2 means the rotation of the point around itself is180 degrees.  [It's confusing I know.  It's all about getting out of a 4D rotation.]

The axis vector of rotation is the point px, py, pz.  That is multiplied by the sine of 180/2.  That ends up being the sine of 90 degrees which equals1.   

point quaternion pw = 0 = cos (180/2) = cos (90) = 0

point quaternion px = px * sin (180/2) = px * sin(90) = px * 1 = px

point quaternion py = py * sin (180/2) = py * sin(90) = py * 1 = py

point quaternion pz = pz * sin (180/2) = pz * sin(90) = pz * 1 = pz


The new point location p'

 To calculate the quaternion rotated location of a point use the formula [NOTE: using quaternion multiplication]

p' = qpq' 

 The order of operation is quaternion p multiplied with q'.  The resulting quaternion m is multiplied by q' to create p'.       m = pq'   and then p' = qm

The values in px', py', and pz' are the rotated x,y,z of the point.

px' = new point location x

py' = new point location y

pz' = new point location z


Quaternion multiplication 

 A quaternion is also written as (qw + qxi + qyj + qzk), where i,j,k represent square root of -1 along 3 complex (imaginary number) axes.  I'm ignoring the 4D complex stuff here because it confused me for a long time.  Lets just look at what happens if you multiply using this format:

(pw + pxi + pyj + pzk) (qw + qxi + qyj + qzk) = 

pw*qw + pw*qxi + pw*qyj + pw*qzk + px*qwi - px*qx + px*qyk - px*qzj + py*qwj - py*qxk - py*qy + py*qzi + pz*qwk + pz*qxj - pz*qyi - pz*qz

                                                          

= (pw*qw - px*qx - py*qy - pz*qz) + (pw*qx + px*qw + py*qz - pz*qy)i + (pw*qy - px*qz + py*qw + pz*qx)j + (pw*qz + px*qy - py*qx + pz*qw)k

 Multiplication is distributive, and there is a multiplication table for i*j*k = -1 (see blow).

The resulting quaternion product of this multiplication is:  

[Note: I decided to call this quaternion m]

mw = (pw*qw - px*qx - py*qy - pz*qz)

mx = (pw*qx + px*qw + py*qz - pz*qy)

my = (pw*qy - px*qz + py*qw + pz*qx)

mz = (pw*qz + px*qy - py*qx + pz*qw)


i*j*k = -1

The multiplication table for i j k

1 i j k

1 1 i j k

i i −1 k −j

j j −k −1 i

k k j −i −1


https://en.wikipedia.org/wiki/Quaternion














Donate





Thursday, September 17, 2020

Criticism of Marxist literary criticism

 Marxist literary criticism is a way of reading a text in which the reader is to identify the power structures, the oppressed, and the symbols of oppression.  In other words, what is the class struggle occurring in the text.  It is intended to show how capitalism is a social structure that oppresses people.  Through Marxist literary criticism the reader should identify that it is the ruling class that has caused the conflict in which the working class protagonist must struggle.  But what is the end result, logical conclusion, the reader is to arrive at when following Marxist literary criticisms?  

  Marx's answer: You are oppressed and it is someone else's fault.  "They" programmed your brain to oppress you.    

  Marx’s Capital states that "the mode of production of material life determines altogether the social, political, and intellectual life process. It is not the consciousness of men that determines their being, but on the contrary their social being, that determines their consciousness." Put simply, the social situation of the author determines the types of characters that will develop, the political ideas displayed and the economical statements developed in the text. - https://en.wikipedia.org/wiki/Marxist_literary_criticism

  And if only you had 'x' your oppression would end.  [Fill in the variable 'x' with stuff i.e. 'the means of production', 'iPhones, 'Nikes', 'Lancome Mascara'... ]  

There is no self improvement in Marxist literary criticism.  Problems would be solved by just taking the thing you are missing and/or disrupting the social/economic system.  

In short, Marxist criticism is a justification of theft.  

Sometimes we are OK with that justification, like increasing the taxes on Jeff Bezos.  But eventually everyone is in front of the barrel of Marx's critical canon.

Firefighter's Dream sports bar destroyed 

Chicago looting

The consequence, improving yourself makes you a target for someone else to blame.

Wednesday, September 9, 2020

How to turn off hard drive write caching on windows 10 industrial PC's

  Some of our industrial PC's now use Windows 10 Enterprise LTSB or LTSC.  Since the change to windows 10 there has been an increase in file corruptions.  A user.config file gets written at the close of a vision inspection program.  If the PC is shut down with the program running, the operating system will close the program.  Hard drive write caching is active by default.  The operating system thinks that the user.config file has been written to the hard drive, but in reality, the file's data has only been moved to the memory.  It may be clear of the PC's RAM, but it has not been written to the physical platter.  Regardless the operating system turns off the computer's power.  When the PC is turned on again, the partial user.config is read.  Since it is incomplete the program does not reload all of the user settings.  Sometimes the corruption is so bad that the program crashes.

  Write caching is turned off from device manager.  

Open device manager, either by typing Device Manager in the search box:


OR open from "ThisPC" properties in file explorer:


In Device Manager, expand Disk drives.  Right click on the drive. Click Properties in the pop up menu.



In the Policy tab you can uncheck Enable Write Caching:


There is not a significant drop in system benchmak score.  However in practical usage of the PC when ever you switch active programs it takes a noticeable amount of time for the new program window to display.

Benchmark with  write caching on:


Benchmark with write caching off:


The next economic crisis is commercial real estate

 This video talks about why New York city real estate is going unrented for years, and why the rent is never lowered.  The building mortgage is placed into a mortgage back security.  The security is sold to multiple investors.  They now have control of how much rent costs.  Unrented space doesn't lower the value of the building because rent can be added at the end of the mortgage.  If the rent is lowered the mortgage is in default because the building value is lower.  That would require the owner of the building to write a huge check to make up the difference.  Since they can add rent to the end of the mortgage that's what they do, instead of taking the out of pocket loss.  The result is, there could be one space in the building that has rent so high that no one could ever pay it.  It keeps the value of the building high enough to stay out of default. 



https://youtu.be/NdfmMB1E_qk

BUT now with covid-19, offices are empty.  this is going to crush the commercial real estate market.  The commercial mortgage backed securities are going to get hit bad.



https://youtu.be/D7ou4-w2fow 

Thursday, June 11, 2020

My spine was fractured in a head on wreck

On my way to MQ, I was hit head on by a old man driving a buick.  It was 11:00 on monday june 8th.
Reading rd cincinnati, north of Lousantiville.  my spine was fractured.

The non graphic slow motion head on dash cam video
https://youtu.be/EhcXnhqEjOA


The Graphic full speed video of the crash.
https://www.bitchute.com/video/bXECo20NBvCF/

Thursday, April 30, 2020

Thermal / Visible fusion with Omron MEMS temperature sensor and Basler Dart



Omron uses Micro-ElectoMechanical System (MEMS) thermopile to measure temperature at a distance.  The D6T series sensors use the thermoelectric effect (Seebeck effect) in which temperature is converted directly to voltage.  They are sensitive to Longware Infrared (LWIR) at wavelength between 8 and 12 micrometers.



 The sensors are intended to detect human presence in a volume the size of a room.  The optics are fixed, and the angular field of view is wide.  The highest resolution sensor, 32 x 32 pixels has a 90 degree angular field of view.  A reasonable human size field of view (1550 mm x 1550 mm) requires a short working distance of 800 mm.



Omron D6T-32L-01A specs
Price $125
Resolution 32 x 32 pixels (1024 total pixels)
Power supply voltage 4.5 to 5.5 VDC
Current consumption: 19 mA
Accuracy: +- 3 degrees C in the center 16 pixels.
Temperature resolution 0.33 degrees C
Communication format: I2C

Omron example image 32 x 32 pixels.


  To get usable detail in the visible spectrum I would recommend narrowing the angular field of view.  An inexpensive USB camera that is <GenICam> complaint is the Basler dart daA1280-54uc (S-Mount).

Paired with an f4.2 mm focal length s-mount lens (with IR cut filter), the 800 mm working distance gives a 685 x 915 mm field of view.  But the camera needs to be rotated on its side.

The resulting field of view with both the Omron and the Basler sitting next to each other:
Thermal 1572 x 1572 mm @ 49.125 mm/pixel
Visible 685 x 915 mm @ 0.714 mm/pixel














Sunday, April 26, 2020

Ultraviolet light to inactivate COVID-19

Ultraviolet light (UVC) can destroy covid19.  Estimates are 67J/m^2 (6.7mJ/cm^2) will deactivate to 99.9%. 
This video talks about what I've learned on the topic and how I use it to decontaminate the mail.
There are links to research papers showing the "dose" ("fluence") of UVC energey in mJ/cm^2. I show how to convert the units to mWatt seconds / cm^2. And how to calculate the average UVC power output from the typical ebay lamp. Always wear polycarbonate safety glasses around UVC.





Links on the subject I found useful:
2020 COVID-19 Coronavirus Ultraviolet Susceptibility (67J/m^2 see Table 2
https://www.researchgate.net/publication/339887436_2020_COVID-19_Coronavirus_Ultraviolet_Susceptibility

Dose to inactivate multiple pathogens
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3925713/table/T2/?report=objectonly

Paper "Can biowarfare agents be defeated with light?"
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3925713/

International ultraviolet association COVID 19 topic
iuva.org/IUVA-Fact-Sheet-on-UV-Disinfection-for-COVID-19
UV - FAQ
http://www.iuva.org/UV-FAQs

The Effects of Mercury Vapour Pressure
http://lamptech.co.uk/Documents/M3%20Spectra.htm

Medium pressure mercury power distribution
https://www.eta-uv.com/en/products/uv-lamps

Testing UV absorption eyewear and sunscreen with a deuterium light source (video)
https://www.youtube.com/watch?v=vwsHRrDYu5o


UV Lamps & UVC Lamp Types
americanairandwater.com/lamps.htm

Ultraviolet Germicidal Irradiation Handbook
https://www.researchgate.net/publication/278717381_Ultraviolet_Germicidal_Irradiation_Handbook

True low pressure ercury lamps are not visible light
"Looking at Mercury Vapour - Periodic Table of Videos"
https://www.youtube.com/watch?v=7ZT7xqwk84E

Tuesday, April 14, 2020

Thermal imaging LWIR differs from CMOS and CCD NIR


There are tutorials online that say you can convert a color camera to an infrared camera.  To be clear, you can remove the IR cut filter and improve the infrared sensitivity of a CCD or CMOS camera.  However, you will not be able to measure temperature in the way that a FLIR thermal camera can.
This is because the thermal cameras detect Long Wave Infrared (LWIR) between 7500 nm and 14000 nm.  Standard video cameras can detect light between 310 nm and 1000 nm (nanometers).



In this chart of a Sony IMX367 color sensor (provided by Matrix-Vision.com), the IR cut filter is indicated in magenta.  Removing the IR-cut filter will allow the R G and B photo-sites (pixels) to absorb energy in the infrared spectrum.
https://www.matrix-vision.com/usb3-vision-camera-with-hi-res-sony-cmos-sensors-mvbluefox3-4.html?camera=BF3-4-0315ZC&col=1&row=pregius

But if the goal is to detect more NIR, just use a monochrome image sensor.  That way the RGB Bayer filter is not limiting any of the pixels.

Wednesday, April 8, 2020

Save camera settings to the camera via Basler Pylon


If a Basler Ace loses power it will lose any changed settings.  Saving the settings in the camera is not easy to figure out.  The video describes the problem, and shows how to use Basler Pylon software to save the settings in the camera.

Save Camera Settings via Basler Pylon

The camera can store all of it's settings for up to three users.  The default user settings, called "User Set 1", are loaded when the camera powers up.  Saving the settings to "User Set 1" is not available unless the software is in "Guru" mode.

Here are the steps you need to follow to save the settings in the camera.
1) Connect to the camera
2) If the feature window is not open, click the "View|Features [cameraname]" menu
3) At the bottom of the feature window, select "User Level : Guru"
4) Access the camera's features by expanding the list.  Click on the "> cameraname" to expand the features.
5) Change the features as needed.  Exposure is in Acquisition control, gain is in Analog control.
6)  Save the to the camera, scroll down and expand "> Configuration Sets".
7) Change "Configuration Set Selector" to "User Set 1"
8) Click the "User Set Save" "Execute" button
9) Change "Default Startup Set" to "User Set 1"
illustration for step 2) open the feature window


illustration step 3) change to Guru

illustration step 4) expand list for the camera


illustration step 5) edit features

illustration steps 6 - 9)

Basler Pylon software download link: https://www.baslerweb.com/en/products/software/