Retrogaming, Single Boards, Natural Language Processing, Computer Programming, Software Engineering
Showing posts with label #coding. Show all posts
Showing posts with label #coding. Show all posts
Monday, 12 February 2024
Fixing Galaxian sound on ARM 8 core
** updated ** I was wrong about adding a mutex. One of the MAME developers, in pointing out I was wrong, also pointed out what was wrong,
and subsequently fixed the issue and more. See https://github.com/mamedev/mame/pull/12034 for details.
Monday, 9 September 2019
Debug C# Cortana Skill Locally
I added a video on how to create a Skill in the cloud, compile it there, then suck it back to a desktop, set debug break points, and continue to debug locally.It doesn't have commentary yet, but I'll get to it.
Wednesday, 18 July 2018
How to invoke Cortana channel actions in node.js
Ugh. It took me a while to figure it out, and I had to reverse engineer some code to do it. There were breadcrumbs, but of course being a newb it wasn't immediately obvious.
Botframework allows you to connect to channels. You are likely invoked from a channel. That means you can send meta-data back to that channel. In the previous version of the framework, you called a method off the Message called channelData to set the JSON response. But channelData is deprecated in favor of the new sourceEvent method. So forget the "Launching apps or websites from a Cortana skill" example (that is in C# and the old way)...
The next hint is in the documentation. sourceEvent takes a map. The old version just took some action in a JSON with a type : LaunchUri and uri : "http://whatever.com/"
What is this map? Well, you can have your bot connected to one or more channels (or "*" for all.) The source code implementing sourceEvent was the final piece. I found examples setting the facebook channel, or using directline... But what is the channel name for Cortana? Well, it is cortana.
Wrapping the JSON up underneath the channel name and magically Cortana will launch the app.
msg.sourceEvent(
{ cortana : {
action : {
type : "LaunchUri",
uri : "https://www.octavianit.com"
}
}
} )
But be careful as Cortana will close the channel after invoking the app (that the protocol maps to). And you should consider that speakers (screenless devices) will not support this behavior and should have a UX alternative.
Monday, 16 July 2018
End to End Developer example video of basic Cortana skill
For those wanting a visual walk through of the process to create a Cortana skill with botframework!
Uses node.js.
Labels:
#ai,
#azure,
#botframework,
#coding,
#cortana,
#development,
#skills
Tuesday, 13 September 2016
Geek Dad: Teaching the boy to code...
I might have finally gotten my sons attention. I've been trying to teach him to code in Java for a couple years, but I am competing with the instant gratification of Scratch.
First attempt went something like this: "Hey dude, look how you can use state machines and state transition diagrams to write a text adventure like Zork!" He was kind of interested in building the map, but I lost him in implementing an actual game complete with inventory and actions.
Next attempt was: "Hey son, remember Wizard's Quest the board game I showed you? We can write that as multiplayer network game (kind of like Dark Forest when I was a kid)." He learned something about polygons and translation from the game board into the computer, but I lost him in implementing the event loop and game rules.
Finally we have: "Dude, when I was 8, I played this game called Chase on a Data General Nova III, and it was cool because like in Tron, you could maneuver the robots chasing you into the walls and escape the grid!" I think I got him this time, because I was able to spin up a framework in a few hours, and the building blocks are all there for adding animation, time/event based movement, and other elements. Almost instant gratification in a couple pages of code.
The rules. You are in an arena with electric fences and robots. The robots can only move horizontally or vertically, but you can move diagonally. The objective is to run away from the robots and attempt to maneuver them into the walls. You win when all the robots are dead. You loose when you run into a wall, a robot gets you, or you exceed 100 moves.
Robots use the difference between their position and your position when deciding to move vertically or horizontally (50-50). If another robot is in the way, they pick a random direction (that can cause them to bump into another robot or wall). Whatever a robot runs into is destroyed, but when one robot hits another, one survives.
First attempt went something like this: "Hey dude, look how you can use state machines and state transition diagrams to write a text adventure like Zork!" He was kind of interested in building the map, but I lost him in implementing an actual game complete with inventory and actions.
Next attempt was: "Hey son, remember Wizard's Quest the board game I showed you? We can write that as multiplayer network game (kind of like Dark Forest when I was a kid)." He learned something about polygons and translation from the game board into the computer, but I lost him in implementing the event loop and game rules.
Finally we have: "Dude, when I was 8, I played this game called Chase on a Data General Nova III, and it was cool because like in Tron, you could maneuver the robots chasing you into the walls and escape the grid!" I think I got him this time, because I was able to spin up a framework in a few hours, and the building blocks are all there for adding animation, time/event based movement, and other elements. Almost instant gratification in a couple pages of code.
![]() |
| The Grid |
The rules. You are in an arena with electric fences and robots. The robots can only move horizontally or vertically, but you can move diagonally. The objective is to run away from the robots and attempt to maneuver them into the walls. You win when all the robots are dead. You loose when you run into a wall, a robot gets you, or you exceed 100 moves.
Robots use the difference between their position and your position when deciding to move vertically or horizontally (50-50). If another robot is in the way, they pick a random direction (that can cause them to bump into another robot or wall). Whatever a robot runs into is destroyed, but when one robot hits another, one survives.
![]() |
| The Tron Maneuver |
Saturday, 11 July 2015
What do you do when...
Today's blog is about image processing. In some down time, I've been trying to figure out what to do to manage my photo library that has grown over 25G. This makes it hard to just upload to the cloud (free services anyway). My first intention was to remove duplicates. But of course, its more fun to tackle the bigger issue. How can I index my library so I can actually query against it?
My first thoughts were; there needs to be a simple way to do some basic image comparisons, so what are they?
1) produce a grayscale histogram
2) produce a color histogram
3) create a CRC
4) gather meta data
If an image is exactly the same, regardless of file name and whatnot that can change if the image is copied, then the CRC (ie Adler) will be the same. The trick is, don't calculate the CRC on the file, but rather the contained image, because if the image is edited or saved (i.e. a copy paste), then the EXIF metadata will get lost. So, trick one, calculate the CRC on the pixel map and at the same time rip out the EXIF metadata to stuff into an XML metadata file. (Cool right? Too bad java libraries do not include mechanisms to extract EXIF from JPEG! But easy enough to borrow some libraries from open source projects.)
While calculating the CRC, that will tell you if the image is exactly the same, you still have the issue of "What if I rotated the image 90 or 180 degrees?" You will have a different CRC, so that mechanism won't help. But you can create a histogram on the image. Then you can compare histograms, and if the image is rotated so it is edge aligned (270,180,90) or bit flipped, if those histograms are equal, the image is the same with high probability. Also, images of the same subject in the same context (background) will also be similar.
So, if you have free rotate or scaled (or otherwise changed the image quality or cropped), the histogram might be a good starting guess. There will be false positives, but from a numerical standpoint, you can then move on to more intensive methods. How to compare? Cosine similarity works. The vector is the histogram, and you can fix the scaling issue by changing the frequency (count) of the color to the percentage (so count over total size). I have a sneaky suspicion this is how the brain does it. When our eyes scan an image, we look for discontinuity in the image (and tend to ignore anything with continuity. That's why "if it were any closer it would bite me.")
I am still thinking about false positives, or how to identify subjects in an image. For subjects, the cosine similarity will also work, but figuring out the threshold of what to suggest to a human could be fun. I need to play with that, but I figure a that with a divide and conquer based on histogram might work. Then also working in some extrapolation methods. I could divide and conquer to generate average colors in a section of an image, and/or use that to generate a polynomial for horizontal and vertical slices. If the coefficients are close, then there is a good bet the images are similar.
My first thoughts were; there needs to be a simple way to do some basic image comparisons, so what are they?
1) produce a grayscale histogram
2) produce a color histogram
3) create a CRC
4) gather meta data
If an image is exactly the same, regardless of file name and whatnot that can change if the image is copied, then the CRC (ie Adler) will be the same. The trick is, don't calculate the CRC on the file, but rather the contained image, because if the image is edited or saved (i.e. a copy paste), then the EXIF metadata will get lost. So, trick one, calculate the CRC on the pixel map and at the same time rip out the EXIF metadata to stuff into an XML metadata file. (Cool right? Too bad java libraries do not include mechanisms to extract EXIF from JPEG! But easy enough to borrow some libraries from open source projects.)
While calculating the CRC, that will tell you if the image is exactly the same, you still have the issue of "What if I rotated the image 90 or 180 degrees?" You will have a different CRC, so that mechanism won't help. But you can create a histogram on the image. Then you can compare histograms, and if the image is rotated so it is edge aligned (270,180,90) or bit flipped, if those histograms are equal, the image is the same with high probability. Also, images of the same subject in the same context (background) will also be similar.
So, if you have free rotate or scaled (or otherwise changed the image quality or cropped), the histogram might be a good starting guess. There will be false positives, but from a numerical standpoint, you can then move on to more intensive methods. How to compare? Cosine similarity works. The vector is the histogram, and you can fix the scaling issue by changing the frequency (count) of the color to the percentage (so count over total size). I have a sneaky suspicion this is how the brain does it. When our eyes scan an image, we look for discontinuity in the image (and tend to ignore anything with continuity. That's why "if it were any closer it would bite me.")
I am still thinking about false positives, or how to identify subjects in an image. For subjects, the cosine similarity will also work, but figuring out the threshold of what to suggest to a human could be fun. I need to play with that, but I figure a that with a divide and conquer based on histogram might work. Then also working in some extrapolation methods. I could divide and conquer to generate average colors in a section of an image, and/or use that to generate a polynomial for horizontal and vertical slices. If the coefficients are close, then there is a good bet the images are similar.
Subscribe to:
Posts (Atom)

