Also See...

You should also check out my non-technology blog at:

http://www.bobsbasement.net/

Fixing Underwater Videos with FFMPEG

I ran into an interesting predicament: I couldn't get the right color adjustment settings to work in my video editor to correct some underwater videos from a scuba diving trip. After much trial and error, I came up with an alternative method: I have been able to successfully edit underwater photos to restore their color, so I used FFMPEG to export all of the frames from the source video as individual images, then I used a script to automate my photo editor to batch process all of the images, then I used FFMPEG to reassemble the finished results into a new MP4 file.

The following video of a Goliath Triggerfish in Bora Bora shows a before and after of what that looks like. Overall, I think the results are promising, albeit via a weird and somewhat time-consuming hack.

Exporting Videos as Images with FFMPEG

Here is the basic syntax for automating FFMPEG to export the individual frames:

ffmpeg.exe -i "input.mp4" -r 60 -s hd1080 "C:\path\%6d.png"

Where the following items are defined:

-i "input.mp4" specifies the source MP4 file
-r 60 specifies the frame rate for the video at 60fps
-s hd1080 specifies 1920x1080 resolution (there are others)
"C:\path\%6d.png" specifies the directory for storing the images, and specifies PNG images with file names which are numerically sequenced with a width of 6 digits (e.g. 000000.png to 999999.png)

Combining Images as a Video with FFMPEG

Here is the basic syntax for automating FFMPEG to combine the individual frames back into an MP4 file:

ffmpeg.exe -framerate 60 -i "C:\path\%6d.png" -c:v libx264 -f mp4 -pix_fmt yuv420p "output.mp4"

Where the following items are defined:

-framerate 60 specifies the frame rate for the output video at 60fps (note that specifying a different framerate than you used for exporting could be used to alter the playback speed of the final video)
-i "C:\path\%6d.png" specifies the directory where the images are stored, and specifies PNG images with file names which are numerically sequenced with a width of 6 digits (e.g. 000000.png to 999999.png)
-c:v libx264 specifies the H.264 codec
-f mp4 specifies an MP4 file
-pix_fmt yuv420p specifies the pixel format, which could also specify "rgb24" instead of "yuv420p"
"output.mp4" specifies the final MP4 file
Posted: Sep 23 2016, 02:45 by Bob | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us
Correlation versus Causation

I just saw this t-shirt and I absolutely love it...

Correlation-versus-Causation

I cannot count the number of times that I have had to explain this simple concept to people who think that something coincidental was the driving force behind a problem which has developed with the technology that they use in their daily lives. For example, imagine the following statement: "I just closed the door and my television no longer works." Those two events obviously sound like completely unrelated events, and yet I have had to answer questions from dozens of people who honestly believe that one inapplicable event like this caused the other unconnected failure.

Oh sure, there are concepts like the Butterfly Effect to consider, but by and large those do not apply in your average, day-to-day situation. More often than not, the cause for most of the technology problems which I help people troubleshoot have nothing to do with what they believe to be the cause. (And believe me - I have heard some amazing theories from various people about the sources of their technological maladies.) My favorite story along these lines is the apocryphal My Car Does Not Like Vanilla Ice Cream story, which I honestly wish was true.

Nevertheless, as a piece of unsolicited advice - when something has gone wrong, it is often best to analyze the failure for what it is instead of trying to analyze what you believe is the origin of your problems.

Posted: Aug 07 2016, 19:54 by Bob | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Troubleshooting | Support
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us
First World Problems

One of the four computer monitors on my desk has died and I'm left thinking, "Well, darn. How am I going to get any work done?"

Office Drawing

(Note: They're actually flat-screen monitors; the CRTs are from Visio.)

Posted: Mar 31 2016, 14:43 by Bob | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Hardware
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us
How to Add the Nik Collection to Corel's PaintShop Pro

Following Google's acquisition of Nik Software, Google has decided to make it's suite of plugins available for free. With that in mind, I thought that I  would post a simple "How-To" guide for using the Nik plugins for anyone who is using Corel's PaintShop Pro instead of Adobe's hideously-priced Photoshop software. (Note that Photoshop is really cool, of course - it's just priced and/or licensed badly.)

In any event, here are the steps to use the Nik Collection plugins with Corel's PaintShop Pro on a Windows computer:

  1. Download the Nik Collection from https://www.google.com/nikcollection/
  2. Install the collection into the default folder; this should be something like the following path:

    "%ProgramFiles%\Google\Nik Collection"

  3. Open a Windows command prompt
  4. Change directory to the plugins folder for the version of PaintShop which you have installed; for example:

    cd /d "%ProgramFiles%\Corel\Corel PaintShop Pro X8 (64-bit)\PlugIns\EN"

  5. Create a directory junction to the Nik Collection:

    mklink /j "Nik Collection" "%ProgramFiles%\Google\Nik Collection"

  6. When you next open PaintShop, the Nik Collection will show up under Effects->Plugins:

    Nik-Plugins-For-Corel-PaintShop-Pro

That's all it takes. Have fun!

Posted: Mar 24 2016, 16:48 by Bob | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Photography
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us
Adventures With Proxy Servers

One of the things about being an ubergeek is setting up a full Active Directory Domain to manage all of the computers in my house and running my own proxy server to provide Internet access for our home network. I am currently using Microsoft's Threat Management Gateway (TMG), and before that I was using Microsoft's Internet Security and Acceleration (ISA) Server - both of which have allowed me to do some fun things.

For example, for one whole year I intercepted all requests for the Google website and sent them to a website which I had created that looked and acted like Google but used the Bing API to provide the results. (No one could tell the difference, and I eventually wrote a blog about my experiment called Fun with Search Engines.)

At other times I would intercept my kids' Internet requests and send them to a "Your Internet is Turned Off" page when they failed to complete their chores; this was often met with much grumbling on their part. (Although one of my daughters learned how to pirate a neighbor's unsecured WiFi connection, and I was too proud of her ingenuity to get upset at her for skirting around the house rules.)

Running my own proxy server was good for accountability, too: I created a program which crawled all of the proxy server logs and created detailed reports that were dumped in a public share so everyone in the family could see where everyone else was browsing. (I'm a parent - so there is no such thing as "Private Browsing" in my house.)

That being said, I recently ran into a situation where I felt it necessary to interfere with the Internet for a few days. I had seen too many people post spoilers on Facebook about who died on The Walking Dead, and my wife saw too many spoilers about what was happening on Downton Abbey. With that in mind, when Star Wars VII  was hitting the theaters, I decided that I needed to block Facebook for a few days.

But I couldn't just "block" Facebook, I needed to have fun with it... so I did this - I sent all requests for Facebook to the following page until my wife and I had a chance to see Star Wars:

http://www.microsoftbob.com/star-wars-warning.htm

Yeah, it's a really simple script - but it did the trick. ;-)

Posted: Feb 11 2016, 00:08 by Bob | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Windows
Tags: ,
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us
Still More Examples of Bad Technical Support

Here is another entry in my on-going list of examples for both good and bad technical support experiences. For this situation, I will show an example of bad technical support as provided by the Microsoft Outlook Support Team.

Here is the scenario: about two months ago one of my Hotmail accounts stopped working with Windows Live Mail. When I attempted to sync that particular email account, I received an error message that was similar to the following example:

Bear in mind, however, that I made no changes to my Windows Live Mail settings, and I have several other Hotmail accounts which are working perfectly with the same settings on the same computer.

So I started a support issue with the the Microsoft Outlook Support Team, and over the next several weeks I went back and forth with several people on that team who were clearly uninterested in working on this issue. (In fact, at one point they simply closed the case without notifying me!) As of today the issue is still not resolved, and I have not heard from anyone at Microsoft within the past month.

As I said before, this is an example of really bad technical support.

With that in mind, listed below is the full thread from my support case in order of the events. Note that I have substituted the following variables where necessary to hide my actual account name, email address, and support number:

  • %ACCOUNT_NAME% is my Hotmail account name
  • %EMAIL_ACCOUNT% is my email address for my Hotmail account
  • %TICKET_NUMBER% is my ticket number for my Microsoft support case (e.g. SRX12345678ID)

So without further narrative, here are all of the notes from the support case.

04/18/2015 15:14

Service: General Issue

What type of problem do you have?

  • Selected Product
    • Outlook
  • Selected Issue
    • Your account has been temporarily blocked

Enter a short description of your issue: Cannot Sync Email from Windows Live Mail

Enter the email address (Microsoft account) affected by this issue: %EMAIL_ACCOUNT%

Enter your contact email address: %EMAIL_ACCOUNT%

Enter a detailed description of your issue:

I was able to sync my %EMAIL_ACCOUNT% account in Windows Live Mail until a week or so ago, and now I receive the following error message:

Unable to send or receive messages for the Hotmail (%ACCOUNT_NAME%) account.
Server Error: 3219
Server: 'https://mail.services.live.com/DeltaSync_v2.0.0/Sync.aspx'
Windows Live Mail Error ID: 0x8DE00005


For reasons that are completely unrelated to this issue, I completely reinstalled Windows 7 Ultimate on this computer, and yet after reinstalling Windows and Windows Live Mail on this computer I still see the same error. In addition, I have a couple of other Hotmail accounts that I use with Windows Live Mail on the same computer and they work without any errors.

With that in mind, the problem should not be caused by any settings on my computer. However, I did not make any changes to my account settings at Hotmail before I started seeing this problem.

There is one thing that I have noticed, though - when I log into the Hotmail.com website, when I use one of my other Hotmail accounts the title bar says Outlook.com, whereas the title bar for my %EMAIL_ACCOUNT% account says Outlook Mail (Preview).

04/18/2015 15:18

From: Microsoft Support

We are writing to let you know that we have received your request for support and will reply within 24 hours.

If you don’t see a message from us within 24 hours, check to see if email from @css.one.microsoft.com is in your junk mail folder. You can check the status of your request on the Microsoft Support site.

https://support.microsoft.com/oas/default.aspx?tp=il&tenant=WOL&sd=winlive&incno=%TICKET_NUMBER%

Thank you,
The Microsoft Support team

04/19/2015 22:51

Subject: %TICKET_NUMBER%
From: Escalation Agent

Hi,

Thank you for contacting Outlook.com support.

My name is Therese and I’m glad you have reached us today. I have read your description and I understand that you are getting an error message when syncing your account at Windows Live Mail. Let me see what I can do for you.

To start off, we appreciate your efforts in isolating the case by uninstalling and reinstalling your Operating System and Windows Live Mail on your computer. You also mentioned that other Microsoft accounts are working fine on Windows Live Mail which tells us that this is not an issue with the mail client but can be an account-related issue.

With that, I would like you to know that I have escalated this case to our Support Specialist for further evaluation. We will get back to you as soon as we have a resolution or if we need more information.

Your patience is highly appreciated.

Regards,
Therese

04/21/2015 11:12

Subject: RE: %TICKET_NUMBER%
From: %ACCOUNT_NAME%

Has there been any progress on this issue?

FWIW - I have included a screen shot of the error message in Windows Live Mail.

Thanks.
--------------------
Attachments:
0x8DE00005.png

04/21/2015 13:17

Subject: %TICKET_NUMBER%
From: Escalation Agent

Hello,

Good to hear from you again. This is John from Outlook.com support.

We appreciate the screenshot that you have provided us. I have checked your service request and found out that your issue is still being handled by our Support specialists and the investigation is still ongoing. Once we got any developments or if there is anything that our Support specialist would need from you, we'll inform you right away.

Thank you for your cooperation and patience on this matter.

Regards,
John

PS: Please do not delete the first email notification from us. If you did not receive another notification in 24 hours, please check the link on the first email notification to see the case progress.

04/25/2015 12:33

Subject: %TICKET_NUMBER% (Reopen)
From: %ACCOUNT_NAME%

It has been a week since I first opened this support case, and from what I could tell - nothing was ever done. So imagine my surprise when I logged in today and I discovered that this support case had been closed without a single notification from Microsoft. This is terrible customer service, and I AM A VERY DISSATISFIED CUSTOMER!!!

At this point I expect three things:

1. I demand that this issue be escalated to someone who can actually work on the issue and resolve it; I no longer want to suffer through working with incompetent 1st-tier support people.

2. I expect to hear from someone within the next 24 hours with an actual update on this issue; I do not want to hear another blasé response which says "the investigation is still ongoing," because it very clearly was not being investigated.

3. I expect to hear from a manager within the next 48 hours as to why this issue was never worked, never resolved, and closed without contacting me.

If I do not hear from anyone within the times that I have put forth, I will escalate this issue through appropriate channels on my own, which will reflect even more poorly on those who have been doing a terrible job thus far.

04/25/2015 16:52

Subject: %TICKET_NUMBER%
From: Escalation Agent

Hi %ACCOUNT_NAME%,

Thank you for your response and for sharing your feelings with us. I’m Froilan, at your service.

We apologize for taking your valuable time in trying to resolve your issue with the error message when syncing your account in Windows Live mail. I fully understand how you feel about the inconvenience this has brought you. Please be informed that I will get back to our Support Specialist to get update about the status of your case. We understand the urgency of this issue; however, we cannot provide you with the time when a reply will be available. Rest assured that this post is being tracked and we will inform you immediately once we get any updates from them.

We appreciate your continued patience in going through this issue.

IMPORTANT REMINDERS:

Please save and keep the first email notification you received after submitting this request. That notification contains the link for this service request. If you did not receive another notification in 24 hours after your reply, you can check the status of this case and view our response by clicking the link on the first notification.

Best regards.

05/01/2015 09:54

Subject: %TICKET_NUMBER%
From: Escalation Agent

Hello %ACCOUNT_NAME%,

How is it going? We received an update coming from our Escalations Engineer and based from what we've observed, it seems the issue is encountered when the server settings for IMAP is not selected.

What you need to do is to make sure that you've selected and followed the Manual Server Settings for IMAP. This should allow the syncing of your accounts.

For more information about this setting, please refer to the IMAP setting that can be found in the link below.

http://windows.microsoft.com/en-US/windows/outlook/send-receive-from-app

Kindly share us the outcome afterwards.

Regards,
Microsoft Support Team

05/03/2015 22:22

Subject: RE: %TICKET_NUMBER%
From: %ACCOUNT_NAME%

This simply does not make sense; I have several other Hotmail accounts which I simply add them to Windows Live Mail and they automatically work. In the Properties dialog for each of my other accounts, the Server Information tab lists "My mail server is an HTTP server" with the following URL:

https://mail.services.live.com/DeltaSync_v2.0.0/sync.aspx

These are the EXACT same settings as the %EMAIL_ACCOUNT% email account. So why would this one account require custom IMAP settings?

Also, this account was working fine until a few weeks ago when I started seeing the errors. I made no changes to my settings, so it would seem that Microsoft has changed something about this specific Hotmail account. As I pointed out before, the web page banner when I am using this account reads "Outlook Mail (Preview)", which leads me to believe that this account was only partially migrated to the new Outlook Mail servers. With that in mind, I would theorize that the problem is due to a failed attempt on Microsoft's behalf when trying migrate my account from the old Hotmail.com servers to the new Outlook.com servers.

05/03/2015 22:23

Subject: %TICKET_NUMBER%
From: %ACCOUNT_NAME%

By the way, while I sincerely appreciate the assistance of the escalation engineer, I still have not heard back from a manager with an answer as to why my support case was closed by the initial support engineer after no work was completed and no attempts were made to contact me.

05/03/2015 23:56

Subject: %TICKET_NUMBER%
From: Escalation Agent

Hi %ACCOUNT_NAME%,

Thank you for providing us additional details. I’m Hyver from Outlook.com Support and I have reviewed the exchange of responses that you had with my colleagues. I’m truly sorry if the issue still persists after a week of communicating with us. I understand the displeasure that you’ve expressed for the support that you experienced. We’re still here to help you on your issue.

I really apologize for the inconvenience that you’ve faced. I know you’re expecting an email from a manager explaining why the support ticket was closed without someone trying to attempt to contact you. I'd like to let you k now that we are actively monitoring cases that are being reviewed by the Escalations Team and we do not close cases with open escalations. So we would like to ask for a copy of the email notification that indicates that the case was closed. I will include this to my reports as this could be an honest mistake or a system glitch,

I totally recognize that you deserve a valid explanation about what happened and we are not letting our customers to be upset at any point of our investigation. We don't like to see our customers upset and inconvenienced and we always strive to create a positive customer experience. With that being said, this should be reviewed again by our Escalations Team and should be taken care with utmost urgency. Please do not lost faith in us as we are doing our best to resolve this issue the soonest possible time.

As we speak, this support request is in our Escalations Team queue and should be treated with immediate attention. We appreciate your cooperation and understanding.

Should you have other questions or clarifications, please do not hesitate to contact us back.

Sincerely,
Hyver

05/05/2015 18:04

Subject: RE: %TICKET_NUMBER%
From: %ACCOUNT_NAME%

Hello Hyver,

There was never an email when the case was closed, which was part of my complaint. If you look at the case notes, you will see that I had to reopen the case on 04/25/2105 when I discovered that the case had been closed when I logged into this support website to check on the status.

05/05/2015 19:47

Subject: %TICKET_NUMBER%
From: Escalation Agent

Hello,

Thank you for letting us know that there was no email with regard to this case that was closed. We will report this to our higher support team and we'll get back to you immediately once we have the latest update from them.

Again, your patience and understanding are much appreciated.

Kindest regards,
Glenda

05/12/2015 22:46

Subject: %TICKET_NUMBER%
From: %ACCOUNT_NAME%

Another week has passed by, and yet I still have not heard anything, which leads me to believe that no one at Microsoft is actually doing nothing with this case. From my perspective, it seems that the "Escalation Agents" with whom I am working are simply stalling for time and hoping that either the problem will go away or I will quit trying and give up.

With that in mind, I will keep everyone up-to-date: the problem is still there - which should be expected since no one at Microsoft appears to be doing anything to fix the problem.

So let me recap the past week or so: I have heard nothing from Microsoft since the last time that I requested an update, my issue is not resolved, and I never heard from a manager at Microsoft with an explanation as to why the front-line engineers closed the case without contacting me or to discuss a plan of action to resolve this issue.

All of this reflects very poorly on the support engineers with whom I am working. As such, I want to work with someone else. Someone who knows what they're doing. Someone who can actually resolve an issue.

05/13/2015 03:37

Subject: %TICKET_NUMBER%
From: Escalation Agent

Note: To check the status of your request, kindly refrain from deleting our email notification. If you haven't received another notification in 24 hours, you can view the agent's response on URL link provided on the notification email.

Hi,

This is Audrey and we apologizer if this case has been going on for so long without any results. Upon checking your concern is still under investigation by our support specialist. We will be making a follow up regarding this and once we have received a word from them it will be immediately relayed to you.

Rest assured that we are exhausting our resources to resolve this matter as soon as possible.

Thank you,
Outlook.com Support Team

05/19/2015 13:36

Subject: %TICKET_NUMBER%
From: Escalation Agent

Hello %ACCOUNT_NAME%,

Sorry for the wait. We received an update coming from our Escalations Team and there's a possibility that your account's server settings were changed. With this, configuring your account to Windows Live Mail using this server "Windows Live Hotmail" will not work.

We are still working on your issue but what you can do is to use IMAP as your server type if you want to sync your emails.

Thank you for consideration and cooperation.

Regards,
Microsoft Support Team

05/29/2015 13:19

Subject: RE: %TICKET_NUMBER%
From: %ACCOUNT_NAME%

I do not wish to use IMAP; I have used that before and it has presented me with a separate series of issues. I will continue to wait for you to fix the problem with the server settings.


To be honest, at this point I have little faith that the Microsoft Outlook Support Team will do anything to resolve this issue. It is abundantly clear to me that the support team is ignoring my support case and simply waiting for me to close it, which I refuse to do since my problem is not resolved.

So once again I reiterate the obvious - this is a perfect example of truly awful technical support, and it demonstrates why many people eventually give up on Hotmail and switch to Gmail.

Posted: Jun 25 2015, 15:44 by Bob | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Microsoft | Support | Windows
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us
Simple Java Wrapper Class for raspistill on the Raspberry Pi 2

Like many self-proclaimed geeks, I can't resist a change to play with new technology. So when the Raspberry Pi 2 was released a short time ago, I didn't hesitate buying one. My first impressions was: for $35, that's a lot of computer power in a very small package. And because I really am a geek, I will admit that the first thing I tried to do with it was to install DOSBOX and run Microsoft Flight Simulator 4...

FS4

Once I got that out of my system, I started experimenting with some simple Java programming and the Raspberry Pi camera module. (It's great that Java is built-into Raspian Wheezy; in the past you had to install it.)

That being said, there isn't any direct I/O control of the camera via Java, although that's pretty much expected. When considering ways to control the camera I came across the Pi4J library, which provides Java-based APIs to control the Raspberry Pi's I/O. This looks like it will be great for me eventually, but for the moment the best idea that I could come up with was to write a simple Java-based wrapper class for the raspistill command line executable.

With that in mind, here's a sample class that you can use to take photos from Java on a Raspberry Pi. I added lots of code comments to explain how everything works, and I'll provide a little more detail after the code sample.

// This class is a very simple Java wrapper for the raspistill executable,
// which makes it easier to take photos from a Java application. Note that
// there are considerably more parameters available for raspistill which
// could be added to this class. (e.g. Shutter Speed, ISO, AWB, etc.) 

public class RaspiStill
{
   // Define the path to the raspistill executable.
   private final String _raspistillPath = "/opt/vc/bin/raspistill";
   // Define the amount of time that the camera will use to take a photo.
   private final int _picTimeout = 5000;
   // Define the image quality.
   private final int _picQuality = 100;

   // Specify a default image width.
   private int _picWidth = 1024;
   // Specify a default image height.
   private int _picHeight = 768;
   // Specify a default image name.
   private String _picName = "example.jpg";
   // Specify a default image encoding.
   private String _picType = "jpg";

   // Default class constructor.
   public void RaspiStill()
   {
      // Do anything else here. For example, you could create another
      // constructor which accepts an alternate path to raspistill,
      // or defines global parameters like the image quality.
   }

   // Default method to take a photo using the private values for name/width/height.
   // Note: See the overloaded methods to override the private values.
   public void TakePicture()
   {
      try
      {
         // Determine the image type based on the file extension (or use the default).
         if (_picName.indexOf('.')!=-1) _picType = _picName.substring(_picName.lastIndexOf('.')+1);

         // Create a new string builder with the path to raspistill.
         StringBuilder sb = new StringBuilder(_raspistillPath);

         // Add parameters for no preview and burst mode.
         sb.append(" -n -bm");
         // Configure the camera timeout.
         sb.append(" -t " + _picTimeout);
         // Configure the picture width.
         sb.append(" -w " + _picWidth);
         // Configure the picture height.
         sb.append(" -h " + _picHeight);
         // Configure the picture quality.
         sb.append(" -q " + _picQuality);
         // Specify the image type.
         sb.append(" -e " + _picType);
         // Specify the name of the image.
         sb.append(" -o " + _picName);

         // Invoke raspistill to take the photo.
         Runtime.getRuntime().exec(sb.toString());
         // Pause to allow the camera time to take the photo.
         Thread.sleep(_picTimeout);
      }
      catch (Exception e)
      {
         // Exit the application with the exception's hash code.
         System.exit(e.hashCode());
      }
   }

   // Overloaded method to take a photo using specific values for the name/width/height.
   public void TakePicture(String name, int width, int height)
   {
      _picName = name;
      _picWidth = width;
      _picHeight = height;
      TakePicture();
   }

   // Overloaded method to take a photo using a specific value for the image name.
   public void TakePicture(String name)
   {
      TakePicture(name, _picWidth, _picHeight);
   }

   // Overloaded method to take a photo using specific values for width/height.
   public void TakePicture(int width, int height)
   {
      TakePicture(_picName, width, height);
   }
}

The wrapper class should be pretty self-explanatory: calling the TakePicture() method with no parameters will use the application defaults, and calling the overloaded methods will allow you to specify the output filename and the width/height for the image. You specify the image type based on the file extension; (e.g. ".jpg", ".png", ".gif"). There are a bunch of additional raspistill options which you can easily add to the application; see the Raspberry Pi camera module page for more information.

Here's a simple application to test it out:

public class CameraTest
{
  // Define the number of photos to take.
  private static final long _numberOfImages = 5;
  // Define the interval between photos.
  private static final int _delayInterval = 5000;

  public static void main(String[] args)
  {
    try
    {
      // Create a new RaspiStill object.
      RaspiStill camera = new RaspiStill();
      // Loop through the number of images to take.
      for (long i = 0; i < _numberOfImages; ++i)
      {
        // Capture the image.
        camera.TakePicture("image" + i + ".jpg",800,600);
        // Pause after each photo.
        Thread.sleep(_delayInterval);
      }
    }
    catch (Exception e)
    {
      // Exit the application with the exception's hash code.
      System.exit(e.hashCode());
    }
  }
}

Now that I've shared this odd little sample, I'll wander back to my dungeon so I can keep playing with my Raspberry Pi.

Note: This blog was originally posted at http://blogs.msdn.com/robert_mcmurray/
Posted: Jun 11 2015, 20:14 by Bob | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Java | Raspberry PI
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us
Simple Java Wrapper Class for raspistill on the Raspberry Pi 2

Like many self-proclaimed geeks, I can't resist a change to play with new technology. So when the Raspberry Pi 2 was released a short time ago, I didn't hesitate buying one. My first impressions was: for $35, that's a lot of computer power in a very small package. And because I really am a geek, I will admit that the first thing I tried to do with it was to install DOSBOX and run Microsoft Flight Simulator 4...

FS4

Once I got that out of my system, I started experimenting with some simple Java programming and the Raspberry Pi camera module. (It's great that Java is built-into Raspian Wheezy; in the past you had to install it.)

That being said, there isn't any direct I/O control of the camera via Java, although that's pretty much expected. When considering ways to control the camera I came across the Pi4J library, which provides Java-based APIs to control the Raspberry Pi's I/O. This looks like it will be great for me eventually, but for the moment the best idea that I could come up with was to write a simple Java-based wrapper class for the raspistill command line executable.

With that in mind, here's a sample class that you can use to take photos from Java on a Raspberry Pi. I added lots of code comments to explain how everything works, and I'll provide a little more detail after the code sample.

// This class is a very simple Java wrapper for the raspistill executable,
// which makes it easier to take photos from a Java application. Note that
// there are considerably more parameters available for raspistill which
// could be added to this class. (e.g. Shutter Speed, ISO, AWB, etc.) 

public class RaspiStill
{
   // Define the path to the raspistill executable.
   private final String _raspistillPath = "/opt/vc/bin/raspistill";
   // Define the amount of time that the camera will use to take a photo.
   private final int _picTimeout = 5000;
   // Define the image quality.
   private final int _picQuality = 100;

   // Specify a default image width.
   private int _picWidth = 1024;
   // Specify a default image height.
   private int _picHeight = 768;
   // Specify a default image name.
   private String _picName = "example.jpg";
   // Specify a default image encoding.
   private String _picType = "jpg";

   // Default class constructor.
   public void RaspiStill()
   {
      // Do anything else here. For example, you could create another
      // constructor which accepts an alternate path to raspistill,
      // or defines global parameters like the image quality.
   }

   // Default method to take a photo using the private values for name/width/height.
   // Note: See the overloaded methods to override the private values.
   public void TakePicture()
   {
      try
      {
         // Determine the image type based on the file extension (or use the default).
         if (_picName.indexOf('.')!=-1) _picType = _picName.substring(_picName.lastIndexOf('.')+1);

         // Create a new string builder with the path to raspistill.
         StringBuilder sb = new StringBuilder(_raspistillPath);

         // Add parameters for no preview and burst mode.
         sb.append(" -n -bm");
         // Configure the camera timeout.
         sb.append(" -t " + _picTimeout);
         // Configure the picture width.
         sb.append(" -w " + _picWidth);
         // Configure the picture height.
         sb.append(" -h " + _picHeight);
         // Configure the picture quality.
         sb.append(" -q " + _picQuality);
         // Specify the image type.
         sb.append(" -e " + _picType);
         // Specify the name of the image.
         sb.append(" -o " + _picName);

         // Invoke raspistill to take the photo.
         Runtime.getRuntime().exec(sb.toString());
         // Pause to allow the camera time to take the photo.
         Thread.sleep(_picTimeout);
      }
      catch (Exception e)
      {
         // Exit the application with the exception's hash code.
         System.exit(e.hashCode());
      }
   }

   // Overloaded method to take a photo using specific values for the name/width/height.
   public void TakePicture(String name, int width, int height)
   {
      _picName = name;
      _picWidth = width;
      _picHeight = height;
      TakePicture();
   }

   // Overloaded method to take a photo using a specific value for the image name.
   public void TakePicture(String name)
   {
      TakePicture(name, _picWidth, _picHeight);
   }

   // Overloaded method to take a photo using specific values for width/height.
   public void TakePicture(int width, int height)
   {
      TakePicture(_picName, width, height);
   }
}

The wrapper class should be pretty self-explanatory: calling the TakePicture() method with no parameters will use the application defaults, and calling the overloaded methods will allow you to specify the output filename and the width/height for the image. You specify the image type based on the file extension; (e.g. ".jpg", ".png", ".gif"). There are a bunch of additional raspistill options which you can easily add to the application; see the Raspberry Pi camera module page for more information.

Here's a simple application to test it out:

public class CameraTest
{
  // Define the number of photos to take.
  private static final long _numberOfImages = 5;
  // Define the interval between photos.
  private static final int _delayInterval = 5000;

  public static void main(String[] args)
  {
    try
    {
      // Create a new RaspiStill object.
      RaspiStill camera = new RaspiStill();
      // Loop through the number of images to take.
      for (long i = 0; i < _numberOfImages; ++i)
      {
        // Capture the image.
        camera.TakePicture("image" + i + ".jpg",800,600);
        // Pause after each photo.
        Thread.sleep(_delayInterval);
      }
    }
    catch (Exception e)
    {
      // Exit the application with the exception's hash code.
      System.exit(e.hashCode());
    }
  }
}

Now that I've shared this odd little sample, I'll wander back to my dungeon so I can keep playing with my Raspberry Pi.

Note: This blog was originally posted at http://blogs.msdn.com/robert_mcmurray/
Posted: Jun 11 2015, 20:14 by Bob | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Java | Raspberry PI
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us
Simple Java Wrapper Class for raspistill on the Raspberry Pi 2

Like many self-proclaimed geeks, I can't resist a change to play with new technology. So when the Raspberry Pi 2 was released a short time ago, I didn't hesitate buying one. My first impressions was: for $35, that's a lot of computer power in a very small package. And because I really am a geek, I will admit that the first thing I tried to do with it was to install DOSBOX and run Microsoft Flight Simulator 4.

Once I got that out of my system, I started experimenting with some simple Java programming and the Raspberry Pi camera module. (It's great that Java is built-into Raspian Wheezy; in the past you had to install it.)

That being said, there isn't any direct I/O control of the camera via Java, although that's pretty much expected. When considering ways to control the camera I came across the Pi4J library, which provides Java-based APIs to control the Raspberry Pi's I/O. This looks like it will be great for me eventually, but for the moment the best idea that I could come up with was to write a simple Java-based wrapper class for the raspistill command line executable.

With that in mind, here's a sample class that you can use to take photos from Java on a Raspberry Pi. I added lots of code comments to explain how everything works, and I'll provide a little more detail after the code sample.

// This class is a very simple Java wrapper for the raspistill executable,
// which makes it easier to take photos from a Java application. Note that
// there are considerably more parameters available for raspistill which
// could be added to this class. (e.g. Shutter Speed, ISO, AWB, etc.) 

public class RaspiStill
{
   // Define the path to the raspistill executable.
   private final String _raspistillPath = "/opt/vc/bin/raspistill";
   // Define the amount of time that the camera will use to take a photo.
   private final int _picTimeout = 5000;
   // Define the image quality.
   private final int _picQuality = 100;

   // Specify a default image width.
   private int _picWidth = 1024;
   // Specify a default image height.
   private int _picHeight = 768;
   // Specify a default image name.
   private String _picName = "example.jpg";
   // Specify a default image encoding.
   private String _picType = "jpg";

   // Default class constructor.
   public void RaspiStill()
   {
      // Do anything else here. For example, you could create another
      // constructor which accepts an alternate path to raspistill,
      // or defines global parameters like the image quality.
   }

   // Default method to take a photo using the private values for name/width/height.
   // Note: See the overloaded methods to override the private values.
   public void TakePicture()
   {
      try
      {
         // Determine the image type based on the file extension (or use the default).
         if (_picName.indexOf('.')!=-1) _picType = _picName.substring(_picName.lastIndexOf('.')+1);

         // Create a new string builder with the path to raspistill.
         StringBuilder sb = new StringBuilder(_raspistillPath);

         // Add parameters for no preview and burst mode.
         sb.append(" -n -bm");
         // Configure the camera timeout.
         sb.append(" -t " + _picTimeout);
         // Configure the picture width.
         sb.append(" -w " + _picWidth);
         // Configure the picture height.
         sb.append(" -h " + _picHeight);
         // Configure the picture quality.
         sb.append(" -q " + _picQuality);
         // Specify the image type.
         sb.append(" -e " + _picType);
         // Specify the name of the image.
         sb.append(" -o " + _picName);

         // Invoke raspistill to take the photo.
         Runtime.getRuntime().exec(sb.toString());
         // Pause to allow the camera time to take the photo.
         Thread.sleep(_picTimeout);
      }
      catch (Exception e)
      {
         // Exit the application with the exception's hash code.
         System.exit(e.hashCode());
      }
   }

   // Overloaded method to take a photo using specific values for the name/width/height.
   public void TakePicture(String name, int width, int height)
   {
      _picName = name;
      _picWidth = width;
      _picHeight = height;
      TakePicture();
   }

   // Overloaded method to take a photo using a specific value for the image name.
   public void TakePicture(String name)
   {
      TakePicture(name, _picWidth, _picHeight);
   }

   // Overloaded method to take a photo using specific values for width/height.
   public void TakePicture(int width, int height)
   {
      TakePicture(_picName, width, height);
   }
}

The wrapper class should be pretty self-explanatory: calling the TakePicture() method with no parameters will use the application defaults, and calling the overloaded methods will allow you to specify the output filename and the width/height for the image. You specify the image type based on the file extension; (e.g. ".jpg", ".png", ".gif"). There are a bunch of additional raspistill options which you can easily add to the application; see the Raspberry Pi camera module page for more information.

Here's a simple application to test it out:

public class CameraTest
{
  // Define the number of photos to take.
  private static final long _numberOfImages = 5;
  // Define the interval between photos.
  private static final int _delayInterval = 5000;

  public static void main(String[] args)
  {
    try
    {
      // Create a new RaspiStill object.
      RaspiStill camera = new RaspiStill();
      // Loop through the number of images to take.
      for (long i = 0; i < _numberOfImages; ++i)
      {
        // Capture the image.
        camera.TakePicture("image" + i + ".jpg",800,600);
        // Pause after each photo.
        Thread.sleep(_delayInterval);
      }
    }
    catch (Exception e)
    {
      // Exit the application with the exception's hash code.
      System.exit(e.hashCode());
    }
  }
}

Now that I've shared this odd little sample, I'll wander back to my dungeon so I can keep playing with my Raspberry Pi.

Note: This blog was originally posted at http://blogs.msdn.com/robert_mcmurray/
Posted: Jun 11 2015, 20:14 by Bob | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Java | Raspberry PI
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us
Follow Up: Converting Text Files to Audio Files

A couple of days ago I posted a blog which I titled Creating an HTML Application to Convert Text Files to Audio Files, in which I showed how to create an HTML Application that will convert a text file to an audio file. I thought that I would follow up that article with a quick demonstration which compares some of the built-in text-to-speech voices that ship with Windows 7 and Windows 8.

For the text in this demonstration I will use Edgar Allan Poe's famous poem titled The Raven, which is one of my personal favorites. (I used to have the poem memorized as a teenager... that might have been when I was going through a Fahrenheit 451 phase.)

Click the above image
to download the text file.

Microsoft Anna (Windows 7)

For the first demo we will take a look at the poem as read by the Microsoft Anna text-to-speech voice, which ships with Windows 7. This voice is acceptable, and certainly better than the text-to-speech voices which shipped before Windows 7 was released. But still, it has a few odd quirks to it, and as a result this voice typically sounds unnatural to me.

Click the above image
to download the MP3 file.

Microsoft David (Windows 8)

For the second demo we will take a look at the poem as read by the Microsoft David text-to-speech voice, which ships with Windows 8. This voice is considerably more acceptable that Microsoft Anna, and it sounds very natural to me. It is obviously a male voice, and several people with whom I have discussed this subject seem to prefer the Microsoft David voice over all the others.

Click the above image
to download the MP3 file.

Microsoft Hazel (Windows 8)

For the third demo we will take a look at the poem as read by the Microsoft Hazel text-to-speech voice, which also ships with Windows 8. This also much better than the text-to-speech voices which shipped before Windows 7, and it has an English accent which makes it fun for converting literary works.

Click the above image
to download the MP3 file.

Microsoft Zira (Windows 8)

For the fourth and final demo we will take a look at the poem as read by the Microsoft Zira text-to-speech voice, which also ships with Windows 8. This voice is my personal favorite, as I find it the most-natural sounding of all the text-to-speech voices which ship with Windows 7; this is the voice that I used for all of my textbook reading assignments.

Click the above image
to download the MP3 file.

In Closing

As a parting thought, the text-to-speech voices which ship with Windows 8 are extremely good in my opinion; they sound very natural, and they are very easy to understand. As a result, I have a tendency to speed up the playback a little when I am using the script which I shared in my previous blog. That being said, I hope these samples help to demonstrate the various text-to-speech voices that are available in the recent versions of Windows.

Note: This blog was originally posted at http://blogs.msdn.com/robert_mcmurray/
Posted: May 28 2015, 19:59 by Bob | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Scripting | HTMLA
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us