Tuesday, 15 January 2013

MAMP: Access denied! #1045 in phpMyAdmin

Have you accidentally changed your  'root' user password from PhpMyAdmin ?


I changed my 'root' user's password, without thinking properly.  From having the default password ('root'), I changed it to ('password'). I've encountered many issues after that.  Luckily (I don't know why), I was able to re-type a password, so I decided to leave it blank: Change Password > NO Password



I did a bit of research until I made it work again. 

The following steps helped me to fix my issue (please don't try it unless you're having the same issue)

1. Open your terminal Applications > Utilities > Terminal

Type the following:
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot 

"-uroot stands for user:root / -proot stands for password:root"

In my case I had to type the following:
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -p
the terminal asked me to Enter a password


Enter password:  (I left this empty as I didn't have a password set, so I pressed ENTER)

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 85
Server version: 5.1.44 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Then, I typed:
mysql> use mysql;

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Now you have to re-set the password. I wouldn't  like to mess things up (more), so I went for the default password ('root'),  I've typed the following:

mysql> UPDATE mysql.user SET Password=PASSWORD("root") WHERE user="root";
Query OK, 1 row affected (0.07 sec)
Rows matched: 1  Changed: 1  Warnings: 0


Last step, flush the user's privileges:

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.08 sec)


Now, to make sure you're on the right direction, make sure your new password matches a config file on MAMP.
Go to:

  MAMP > Bin > PhpMyAdmin > config.inc.php 

Look for the following line of code:

 $cfg['Servers'][$i]['password']      =  'root';  <- type whatever password you've set. 


You should be able to log your PhpMyAdmin, however you might not be able to access some of your databases. This is because your user 'root' probably hasn't got all privileges.

Now, Click on any database that might allow you to enter the PRIVILEGES tab.

Got to 

 user: root >  EDIT

Database specific privileges
  (choose the DB you're having issues with) > Go

Select ALL Privileges > Tadah! 
You NOW should be able to enter your DB without any issues. 

Happy days!

Hope this works for you. 
As I said, If you haven't got the same issue as mine, please don't try it.








Friday, 4 March 2011

MVC part 2

This week I have worked on my frame design and the set  of frames i'll be using in my application.
Once the image has been captured it's time for some action.

Firstly, I have created an XML file, where I've stored my frames by name & url. Then I proceded to load my xml file from the beginning of the application (Main.as).

Then, within the CaptureView, I have created a loop containing 7 buttons (each one of them for each of the frames previously stored on my XML). When clicking each one of the buttons, this data is sent to my controller (where I keep a 'switch case'). Depending on the button clicked, a string is then passed to the controller and this references the model, where there is a function that sets the frame string and dispatches an Event that the CaptureView class listens for and updates the frame through a function that contains a switch case that adds each frame on the stage.

The problems I've had throughout this process were to retrieve each one of the button's names (in the loop). This was done by creating a document class for these button(s), where there's a function that returns the button's name (String). By calling this function it retrieves the name of the frame, so that this one is then ready to be sent to the Controller.

appController.frameControl(e.currentTarget.fName);

My second issue was to get rid of an added frame when clicking on any other frame button. 
To resolve this I have added an if statement within my updateFrame function. This means if a frame has been added onto stage, in order to preview another one, any frame must be non-existent, so this removes any frame already on stage, leaving space for a new one.

                        if(current_frame)
{
removeChild(current_frame);
current_frame = null;
}

 I am now working on loading my filters, so that I can add them in little icons for the user to utilize them. The next step will the the merging of the frame+image and filter, to be ready for encoding!

Photorama is looking like this:
(Please note the graphics are not quite finished!)






Friday, 25 February 2011

Splitting my prototype onto MVC


After completing my prototype, it was now time to split whatever I had onto MVC.
So far I have created my folder structure, a few VIEWS, a MODEL and a CONTROLLER.

So to start with this process, I had to start designing my main and most important view: The booth itself.
For this I've imported all the images i needed and I have made its view class, this is called the CameraView.

CameraView basically contains the "video" coding, to allow the camera to start, as well as a capture button.
This capture button calls a model method, and this will dispatch an Event that a new view (called CountDownView) will listen for. This then triggers a time countdown (3 seconds). Once the countdown reaches 1, this tells the model to dispatch an Event. In order to capture the image, CameraView will listen for this and will send the BitmapData to CaptureView... phew!, such a long process for a single snapshot!.

This looks like the following:

Saturday, 19 February 2011

Image Printing!

Once the image is encoded, the printing function should send the encoded data we are sending.
To make this happen i've made use of flash.printing.PrintJob.

For this i created a new function where i'm adding my print variable and a new PrintJob.

In order to get the "PrintJob" working we must let it know when to start, what to send to print and when to send it. So basically the data we are sending takes our previous effort of changing bitMaps to bitmapData to a new level, converting your data from bitmapData to bitmap and onto a Sprite... (phew!)

Once you have your Sprite ready (frame+the image+filter previously merged), the content of what we want to print has to make use of another PrintJob method, addPage().

addPage() sends the specified Sprite as a single page. Using this method involves adding the parameters required: a Sprite, and a rectangle (specifying the width and height of your Sprite).

toPrint.addPage(sprite, new Rectangle(0, 0, sprite.width, sprite.height), options)

So when clicking on the PRINT button, you'll get something like this:



In my case, I haven't got a printer plugged to my laptop, so i'll get a pdf version of it, in order to preview it.







This is the result!:






Friday, 18 February 2011

Saving an Image [and its process behind].

Hello,
during the last couple of days i've been trying to implement the 'download' option to my prototype app.

I've included a jpegEncoder plug-in in my root folder, so i could transform my bitmaps to ".jpg".

When applying a filter to a captured image, this is still a bitmap. I came up with some issues and had to do a research in order to fix issues.

The jpegEncoder doesn't take a bitmap for encoding, it takes a bitmapData object instead. My first issue was to encode my image and its filter. I discovered i was only encoding the image itself because the encoding was taking my bitmapData object (in this case the image from the video). So in order to add the filter to my image i had  to change my code slightly and use a property that i've never used before ".applyFilter".

So from using this:
                             bitMap.filters = [filter];
I've modified it to this:
                             bitMapData.applyFilter(bitMapData ,rect, point, filter);

This does exactly the same thing, it applies a filter, the only difference is that applies it to a bitmapData object and takes another 2 arguments in case you decide to move the filter from its position on the image.

Once the image (bitmapData) has got its filter, now can be encoded. Encoding a bitmap is pretty straight forward: it can be done in 2 lines of code!


                            jpegEnc =  new JPGEncoder(85);
                            jpegF = jpegEnc.encode(img);
Now that the image has been encoded and has its filter, there's one thing missing: the frame.

In this case my frame is a MovieClip. Then again i have to convert this MovieClip into bitmapData.
Once the frame has been converted there's no way to include it or concatenate it in the encoding process.

To make this happen and to add these three elements in one i had to make another function to merge them.




The copy pixels property copies a rectangular area of an image to a rectangular area at the destination point of the bitmapData object. So let's say i'm copying the bitMapData var (my image) to the Frame, this means i'm copying it and placing it on top of the frame using this point (28, 26).

The three elements have been merged and encoded, now my next step would be to download or save the picture on my computer.

This was done by adding fileReference.save() to my class.

fileReference.save() takes two arguments, the data & the file's name (concatenating the file extension, in this case .jpg). This procedure works just fine when clicking on the 'download' button.

The way it works is quite familiar, you will get a box where you can assign a name for your file, choose the location where you want to save your picture and click "save" or "cancel".  By clicking on save,  you get the picture on your location (i.e. on your desktop).

                   myFileReference.save(myEncodedPhoto,  fileName + 'extension .jpg');

My project has the ability to save a picture now!.

here's the result!

Thursday, 10 February 2011

Pixel Bender [my very first innocent filter] & AS3 classes.

Hello,

Over the last weekend I spent hours reading and researching about Pixel Bender. I'm contradicting myself a bit from my last post, since i didn't touch anything that is MVC related.
I wanted to give it a go and create my first Pixel Bender Filter, so that I could implement it in my AS3 class (the one shown below).

Pixel Bender syntax is a bit different from AS3, and has some limitations.

The ideas i've got for the filters i'd like to apply on my application are pretty simple, nothing pretentious or extreme: a polaroid-like filter, a nostalgic vintage filter and a double exposure filter, to name a few.

To start with Pixel Bender I had to look at existing filters and tweak them a bit, to see what results are taking effect when modifying the code. Pixel Bender samples and modifies a single pixel from an input image, then applies the 'pixel effect' to the rest of the pixels in a photo. The bad news is PB does not allow any loops when exporting files to Flash, however you can create interesting filters which you can apply to your flash movies or images.

There's an amazing feature within PB which allows you to create parameters. One can develop these and then modify whatever effect you've created by making use of slide bars!


          


I've created a very "innocent" filter, that i haven't applied to my AS3 class (yet).

hours later.....

I've finally managed to implement a filter onto my AS3 class. The process was just a tiny bit complicated as I had never worked with 'Shaders' before.


Shader belongs to the flash.display package, a Shader represents a shader Kernel from Pixel Bender. ShaderFilter belongs to the flash.filters package. This class applies a filter by executing a Shader and affects the object being filtered.

To make the filtering happen, I had to load the filter file (from PB), using the URLLoader (flash.net package). Pixel bender filters are BINARY data, so this has to be specified too.

Once the filter has been loaded, it listens for an Event and here is where the magic happens...


The 'shaderVar'  variable is my Shader (the PB Kernel),  i needed to pass the binary data the loader has imported (previously assigned within the load function). Then I made a new filter and assigned the shaderVar (that already contains the binary data).
The  new 'filter' is the one i'm going to assign to my image.

The 'bitMap' variable is the image the video captures when a user clicks on the "capture" button (this one already contains the video data), so by adding the property "filters" we can assign the filter we have created (it's like adding any other built in filter).

One of problems I had was to actually understand why I had to use squared brackets for [filter], this is because it's expecting an array.



The final result of applying a filter is the following:

The right image is the one the camera shows.
The left image is the result, with a filter added automatically after the capture.


Friday, 4 February 2011

Final Project

Hello Everybody, this last trimester i've decided to create a photo application, it's called Photorama.
I'll be developing Photorama, using as3, pixel bender (mainly). 




This week I've done some research about how to activate a computer's camera using as3. I have also gone over pixel bender,  on how to create filters and to understand how the syntax works. 

So far i've created a prototype of a very simple photo booth application, using as3.

The way I have approached the camera activation is by instantiating a camera & video in my as3 document. 
Then I had to make an "if" statement: "if the camera exists in the device, this creates (addChild) my video (attaching the camera to it), if not, trace that a camera has not been found". 



The camera allowance is part of adobe flash, which can be done by importing the following:
        import flash.media.Camera;
import flash.media.Video;

 To this point, I have not added any plug-ins or extra folders to make the camera access.
The result of the mentioned is the following:


By clicking on "Allow", you are allowing flash to make use of your device's camera. This activates it and displays the live video of what the camera is pointing at. (It does not record whatever it is displaying). 



The next step was a bit confusing to me: to capture an image by clicking a button.
I had to play around using Bitmap & BitmapData (you can work with pixels of a bitmap object).
So I went over the same thing again, instantiating both (Bitmap & BitmapData) and giving them a variable name to each one of them. In my "capture" function, I added both variables and parsed the video (child) variable to the BitmapData variable I had previously instantiated (setting widths & heights for the video itself and the "final" product, being the actual photo taken). 
bitmapData.draw(video);

After a bit of time playing around I came up with a positive result (please don't laugh at my appearance):


The 'photograph' on the left hand side is the video, the real time display. The one on the right hand side is the photograph taken by clicking on the little camera icon. 


Now the next step is to add a 'flash' looking light and then capture the photo, this way the photos can look brighter.. 

There is a lot to do, as this is only a prototype, "simple game" style app. I will be looking into MVC this weekend and starting to implement at least one filter to analise how the coding is going to be distributed in the as3 classes.