Blog

Solving OpenCV GPU Image Stitching Error (SurfFeaturesFinderGpu)

HI Guys!

Two years since I posted something here. Everything seems new. WordPress has changed the back-end completely! Its fortunate to come back with something (probably!) useful for the community. Today’s one is very special and exclusive, in fact I feel I am relieved from a big pain.

In fact I was banging my head with the wonderfully crafted vaguely implied vague error happening inside somewhere in the OpenCV CUDA Built Binaries. In fact this issue is still open in OpenCV Github (https://github.com/opencv/opencv/issues/6231).

The Run Time Error Message was:

The function/feature is not implemented (You should explicitly call download method for cuda::GpuMat object) in cv::_InputArray::getMat_, file ~\opencv\modules\core\src\matrix.cpp, line 1276

However, the actual issue was in Line 483 of this file:

opencv/modules/stitching/src/matchers.cpp

Basically, the original developer was trying to create a grayscale copy of one GpuMat into another GpuMat in the function cvtColor(). As you know this function receives Mat as input, there is a mismatch in the typecast. There is no default Mat(GpuMat) cast. So, when you try to use Extended Features 2D module and GPU computing, you can not use the Gpu Version of the Feature Finder.

I changed the line:

cvtColor(image_, gray_image_, COLOR_BGR2GRAY);

Firstly, I took one temporary Mat and put the gray-scale copy  in it. Then I uploaded it on GPU memory:

Mat gray_image; //TEMPORARY STORAGE FOR GRAY IMAGE
cvtColor(image, gray_image, COLOR_BGR2GRAY); //CREATE THE GRAY IMAGE
gray_image_.upload(gray_image); //SEND THE GRAY IMAGE TO GPU COUNTERPART

And built OpenCV again. The Issue was there no more. Hope this helps!

I am planning to come up with another post on how painfully I built the CUDA Enabled Binaries properly and enjoying now ! ūüôā See you then.

Advertisements

Tizen Certificate file not found : C:\tizen-sdk-data\keystore\

Happened to face the error after first installing the Tizen IDE? Normally, it happens when you install the Tizen IDE and SDK in other folder than C:.

The exact error message is: java.io.IOException: Certificate file not found : C:\tizen-sdk-data\keystore\author\******

Please follow these steps to solve the issue:

  1. Go to Window>Preferences in TizenIDE.
  2. Select Tizen SDK > Security Profiles from the left TreeView. You will see the IDE is looking for Certificate files in C:\tizen-sdk-data… though you installed it in another location.
  3. Select the Author Certificate and click on the immediate Edit Button. Change the path accordingly.
  4. Now change the path of Distributor Certificates in the same way.
  5. Then Click on the Generate Button.
  6. A new form will come, put values as required. You can provide anything you like. Click OK, it will confirm the new certificate creation.
  7. Now Clean the projects and run.

Alternate/Switch Picture For Products On Hover in NopCommerce


Being apart from NopCommerce for years, I thought it would be great to start on the latest version and try to implement some basic functionality that base nop is missing. Today I would like to share my implementation of alternate picture for Products.

I picked up this item as I was trying to design a new Theme for nop. I was just following a Magento Theme I own. But surprisingly did not find any default way to show alternate picture for a product when I hovered. This is just basic. Some may find it useful; others will treat this as a novice work. I appreciate both the views; there are always¬†people know better than you. ūüôā

Step 1: Add a model for Alternate Picture.

 ~\Presentation\Nop.Web\Models\Catalog\ProductDetailsModel.cs

a. Please add this line in the constructor:  AlternatePictureModel = new PictureModel(); My one looks like:

public ProductDetailsModel()
{
 DefaultPictureModel = new PictureModel();
 AlternatePictureModel = new PictureModel(); //meer
 PictureModels = new List<PictureModel>();
 ...................

b. Add the Getter Setter.

//picture(s)
 public bool DefaultPictureZoomEnabled { get; set; }
 public PictureModel DefaultPictureModel { get; set; }
 public PictureModel AlternatePictureModel { get; set; } //meer
 ...............

~\Presentation\Nop.Web\Models\Catalog\ProductOverviewModel.cs

a. Please add this line to the constructor: AlternatePictureModel = new PictureModel();

public ProductOverviewModel()
{
 ProductPrice = new ProductPriceModel();
 DefaultPictureModel = new PictureModel();
 AlternatePictureModel = new PictureModel(); //meer
 .....

b. Don’t forget the Getter Setter:

//picture
 public PictureModel DefaultPictureModel { get; set; }
 public PictureModel AlternatePictureModel { get; set; } //meer

Step 2: Enable the Caching

~\Presentation\Nop.Web\Infrastructure\Cache\ModelCacheEventConsumer.cs

a. Add these lines anywhere in the file:

/// <summary>
 /// Key for default alternate picture caching (all pictures)
 /// </summary>
 /// <remarks>
 /// {0} : product id
 /// {1} : picture size
 /// {2} : isAssociatedProduct?
 /// {3} : language ID ("alt" and "title" can depend on localized product name)
 /// {4} : is connection SSL secured?
 /// {5} : current store ID
 /// </remarks>
 public const string PRODUCT_ALTERNATEPICTURE_MODEL_KEY = "Nop.pres.product.detailspictures-{0}-{1}-{2}-{3}-{4}-{5}-{6}";
 public const string PRODUCT_ALTERNATEPICTURE_PATTERN_KEY = "Nop.pres.product.detailspictures";

Step 3: Setup the Controller for the Alternate Image

~\Presentation\Nop.Web\Controllers\ProductController.cs

a. Add the lines given in b. in the #product Region after

//all pictures
 var pictureModels = new List<PictureModel>();
 foreach (var picture in pictures)
 {
     pictureModels.Add(new PictureModel()
     {
         ImageUrl = _pictureService.GetPictureUrl(picture, _mediaSettings.ProductThumbPictureSizeOnProductDetailsPage),
         FullSizeImageUrl = _pictureService.GetPictureUrl(picture),
         Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat.Details"), model.Name),
         AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat.Details"), model.Name),
     });
 }

b. Lines to Add:

 var alternatePictureModel = new PictureModel(); //meer
 if (pictures.Count() > 1)
 {
     alternatePictureModel = new PictureModel() //meer
     {
         ImageUrl = _pictureService.GetPictureUrl(pictures[1], defaultPictureSize, !isAssociatedProduct),
         FullSizeImageUrl = _pictureService.GetPictureUrl(pictures[1], 0, !isAssociatedProduct),
         Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat.Details"), model.Name),
         AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat.Details"), model.Name),
    };
 }
 else
 {
     alternatePictureModel = null;
 }
 return new { DefaultPictureModel = defaultPictureModel, PictureModels = pictureModels, AlternatePictureModel = alternatePictureModel }; //meer
 });

c. Followed by:

model.DefaultPictureModel = cachedPictures.DefaultPictureModel;
model.AlternatePictureModel = cachedPictures.AlternatePictureModel; //meer

Step 4: Change the ProductOverviewModel Preparation

~\Presentation\Nop.Web\Extensions\ControllerExtensions.cs

a. Search for the function: public static IEnumerable<ProductOverviewModel> PrepareProductOverviewModels

b. Add these lines in the  #region Prepare product picture just before the #endregion:

if (pictureService.GetPicturesByProductId(product.Id).Count() > 1)
{
     model.AlternatePictureModel = cacheManager.Get(alternateProductPictureCacheKey, () =>
    {
         var picture = pictureService.GetPicturesByProductId(product.Id, 2).ElementAt(1);
         var pictureModel = new PictureModel()
         {
               ImageUrl = pictureService.GetPictureUrl(picture, pictureSize),
               FullSizeImageUrl = pictureService.GetPictureUrl(picture),
               Title = string.Format(localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
               AlternateText = string.Format(localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name)
         };
         return pictureModel;
    });
 }
 else
     model.AlternatePictureModel = null;

Step 5: Change the product box UI to fit this change

~\Presentation\Nop.Web\Views\Shared\_ProductBox.cshtml

a. Replace the DIV CLASS=”picture” with the following code:

<div class="picture">
    <a class="default-picture" href="@Url.RouteUrl("Product", new { SeName = Model.SeName })" title="@Model.DefaultPictureModel.Title">
       <img alt="@Model.DefaultPictureModel.AlternateText" src="@Model.DefaultPictureModel.ImageUrl" title="@Model.DefaultPictureModel.Title" />
    </a>
    @if(Model.AlternatePictureModel != null){
          <a class="alternate-picture" href="@Url.RouteUrl("Product", new { SeName = Model.SeName })" title="@Model.DefaultPictureModel.Title">
             <img alt="@Model.DefaultPictureModel.AlternateText" src="@Model.AlternatePictureModel.ImageUrl" title="@Model.DefaultPictureModel.Title" /> <!--meer-->
          </a>
    }
 <script type="text/javascript">
 $(document).ready(function () {

         $('.default-picture').bind({
                mouseenter: function (e) {
                      // Hover event handler
                      var $default_picture = $(this);
                      var $alternate_picture = $(this).next('.alternate-picture');
                      if($alternate_picture.length)
                      {
                             $default_picture.slideUp();
                             $alternate_picture.slideDown();
                      }
                },
                mouseleave: function (e) {
                }
         });
         $('.alternate-picture').bind({
                mouseenter: function (e) {
                },
                mouseleave: function (e) {
                           // Hover event handler
                           var $default_picture = $(this).prev();
                           var $alternate_picture = $(this);
                           $default_picture.slideDown();
                           $alternate_picture.slideUp();
               }
        });
 });
 </script>
 </div>

* I added only the basic UI change, you can add eye candies matching your interest.

Step 6: Add the CSS Classes:

~\Presentation\Nop.Web\Themes\DefaultClean\Content\styles.css

a. Add these two classes anywhere in this file:

.alternate-picture { display:none; } /* meer */
.default-picture { display:block; }

Now you are ready to run your site and start debugging if anything breaks. I checked this code in my PC with VS2012. Hope there is no compile errors, I may have left some TYPOs.

However, there is no live demo unfortunately. But I am providing screenshot of what it looks:

Picture on Load:

default-picture

Changed Picture when Hovered:

alternate-picture

 

 

 

 

 

Happy Coding!

Debug certificate expired on Eclipse for Android and after else…..

This was the 3rd time, I ran into this issue. The debug certificate expired. No where in the project, I could find an error but while trying to Run/Debug my application, the message “Your program contains error…..” was shown. Finally, I found the debug certificate was expired. In the error list I saw:

Error generating final archive:
Debug certificate expired on 1/30/13 3:39 PM!

Hmm, seems I know it. I went to my .android folder and just deleted the debug.keystore file. I know Eclipse will regenerate this file. And it worked.

But while trying to run the application,

Re-installation failed due to different application signatures.
You must perform a full uninstall of the application. WARNING: This will remove the application data!
Please execute ‘adb uninstall com.something.something’ in a shell.
Launch canceled!

I think I remember the next best thing I did the last time. Wiped user data from the Emulator. Mmm, it should work and it worked. Voila! Is it the right way?? I don’t think so,¬†I searched for a better solution and got the following information after google-ing a bit, I think would be great to list in this blog. [If no one finds this useful, at least I can have reference for future!! I know, I know this is a very primitive issue for droid-ers :-)].

 

developer.android.com: The self-signed certificate used to sign your application in debug mode (the default on Eclipse/ADT and Ant builds) will have an expiration date of 365 days from its creation date.

 

So, I would like to use the keytool.exe to set expiry of my debug certificate as long as I want.

The parameter -validity will take values in days for the expiry of the certificate. So, this made my certificate valid for 9000 days. I don’t know if I would work on Android that long…:-)

 

keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 9000

ASP.net :: Crystal Report Toolbar not working?

So many of you may have faced this problem while developing reports with Crystal Report in ASP.net. When you test your site with only Internet Explorer, it works! But when you try with other browsers, the buttons are not working as intended. If this is the case, please copy the Report/Data Loading codes from Page_Load event to Page_Init event. Then see the output. ūüôā Happy Coding!

Postback not working in jQuery UI’s Dialog?

Today while working with the jQuery UI’s Dialog in an ASP.net Application, surprisingly¬†none of the PostBacks were working inside the Dialog! Even I was stumbled when the button click was not caught in Debug Mode.

After a brief look at the generate code with Chrome Developer Tool, I saw jQuery is taking the Entire Dialog Content outside ¬†of the <form runat=‚ÄĚserver‚ÄĚ> tag. ¬†This made my PostBack no longer function as expected.

Luckily the fix was evenhandedly easy with jQuery itself. ūüôā

Just moved the Dialog content back inside the¬†<form runat=‚ÄĚserver‚ÄĚ> tag.

My Original Code:

$('#dialog1').dialog({
	autoOpen: false,
	width: 800,
	buttons: {}
});

The Code with Fix:

$('#dialog1').dialog({
	autoOpen: false,
	width: 800,
	buttons: {},
	open : function(type, data){
	    $(this).parent().appendTo("form");
	}
});

Only added:

open : function(type, data){
    $(this).parent().appendTo("form");
}

as Parameter and it worked the charm!!!

Product Audio/Video Preview in nopCommerce

Showing a preview of the digital products helps to grab the Potential Customers since ads are always made to be lucrative and eye-candy. The Store owners need this feature to Attract Customers and Customers want to have a preview of the Product to see what they are actually opting for. So, for this vice-versa relationship between the views of the Store Owners and Customers often requires the developer to integrate this feature. However, to be candid, I was required to develop this for my Customer (Unless I would not have thought about it!) and now think it would be nice to share with you (Tough This is for 1.30v)

I have place everything in this location. For playing the Videos and Audios I have used flowplayer (http://flowplayer.org/) that is free for non commercial usage.

Instruction is given in the Downloadable File in instructions.txt file.

Please add these lines in web.config in appropriate section:

<section name="PreviewProvider" 
type="NopSolutions.NopCommerce.DataAccess.Media.DBPreviewProviderSection,
Nop.DataAccess" 
requirePermission="false"/>      
<PreviewProvider 
defaultProvider="SQLPreviewProvider">
<providers>
<add name="SQLPreviewProvider" 
type="NopSolutions.NopCommerce.DataAccess.Media.SQLPreviewProvider, 	
Nop.DataAccess.SqlServer" 	
connectionStringName="NopSqlConnection"/>      
</providers>    
</PreviewProvider>