Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TakePhotoFromCameraAction and next try active TCameraComponent


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 15 - Last Post: Apr 3, 2017 1:48 PM Last Post By: Markus Humm
José Morango

Posts: 19
Registered: 10/2/14
TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 10, 2017 9:32 AM
When I take a photo using TakePhotoFromCameraAction and then in another Form
needed to activate a camera by TCameraComponent gives the following error:

"java.lang.RuntimeException: getParameters failed (empty parameters)"

I think it's the TakePhotoFromCameraAction that does not free the camera from the device.
Does anyone know how to solve it?
Does anyone know how to force the release of TakePhotoFromCameraAction?
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 10, 2017 2:25 PM   in response to: José Morango in response to: José Morango
José Morango wrote:

When I take a photo using TakePhotoFromCameraAction and then in another Form
needed to activate a camera by TCameraComponent gives the following error:

"java.lang.RuntimeException: getParameters failed (empty parameters)"

Can you give the exact steps to raise this error?

I created a project with a TakePhotoFromCameraAction, a TCameraComponent, and 2 buttons. The first button executes the
action, and the second sets the TCameraComponent active. Clicking the first and completing the action, then clicking
the second raises no error.

Are you waiting for the action to have been completed before attempting to set the camera active?

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 11, 2017 1:34 AM   in response to: Dave Nottage in response to: Dave Nottage
Am 10.02.2017 um 23:25 schrieb Dave Nottage (TeamB):
José Morango wrote:

When I take a photo using TakePhotoFromCameraAction and then in another Form
needed to activate a camera by TCameraComponent gives the following error:

"java.lang.RuntimeException: getParameters failed (empty parameters)"

Can you give the exact steps to raise this error?

I created a project with a TakePhotoFromCameraAction, a TCameraComponent, and 2 buttons. The first button executes the
action, and the second sets the TCameraComponent active. Clicking the first and completing the action, then clicking
the second raises no error.

Are you waiting for the action to have been completed before attempting to set the camera active?

And maybe it's related to some specific device or Android version?
It might be helpful to give that information as well.

Greetings

Markus
José Morango

Posts: 19
Registered: 10/2/14
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 13, 2017 1:36 AM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:
Am 10.02.2017 um 23:25 schrieb Dave Nottage (TeamB):
José Morango wrote:

When I take a photo using TakePhotoFromCameraAction and then in another Form
needed to activate a camera by TCameraComponent gives the following error:

"java.lang.RuntimeException: getParameters failed (empty parameters)"

Can you give the exact steps to raise this error?

I created a project with a TakePhotoFromCameraAction, a TCameraComponent, and 2 buttons. The first button executes the
action, and the second sets the TCameraComponent active. Clicking the first and completing the action, then clicking
the second raises no error.

Are you waiting for the action to have been completed before attempting to set the camera active?

And maybe it's related to some specific device or Android version?
It might be helpful to give that information as well.

Greetings

Markus

The Android that I have and give me this error are:
- Samsung Galaxy Tab3 Lite, Android 4.4.4
- Mobii M7410, Android 5.1
- OnePlus one, Android 6.0.1
- Motorola XSytle, Andoid 6.0.1

José Morango

Posts: 19
Registered: 10/2/14
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 13, 2017 1:22 AM   in response to: Dave Nottage in response to: Dave Nottage
I use TakePhotoFromCameraAction to take a picture, then I use the
TCameraComponent to read Qr-Code with the Zxing library.
Qr-Code always works until I take a picture (TakePhotoFromCameraAction),
after taking the photograph I try to read the Qr-Code from TCameraComponent
and gives the error: "java.lang.RuntimeException ..."
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 13, 2017 2:41 AM   in response to: José Morango in response to: José Morango
José Morango wrote:

I use TakePhotoFromCameraAction to take a picture, then I use the
TCameraComponent to read Qr-Code with the Zxing library.
Qr-Code always works until I take a picture (TakePhotoFromCameraAction),
after taking the photograph I try to read the Qr-Code from TCameraComponent
and gives the error: "java.lang.RuntimeException ..."

An example project that reproduces the issue might help.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
José Morango

Posts: 19
Registered: 10/2/14
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 13, 2017 5:45 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
José Morango wrote:

I use TakePhotoFromCameraAction to take a picture, then I use the
TCameraComponent to read Qr-Code with the Zxing library.
Qr-Code always works until I take a picture (TakePhotoFromCameraAction),
after taking the photograph I try to read the Qr-Code from TCameraComponent
and gives the error: "java.lang.RuntimeException ..."

An example project that reproduces the issue might help.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

I've created an example the most similar to my project.
The error continues.
After a few more tests, I also read Qr-Code and then I can not take a picture.
One component after initialization does not allow the other to start the camera.

Follow the link to download:

https://www.dropbox.com/s/2bjg5i11j5mwma8/TesteTCamera_ActionList.rar?dl=0
José Morango

Posts: 19
Registered: 10/2/14
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 13, 2017 5:48 AM   in response to: José Morango in response to: José Morango
José Morango wrote:
Dave Nottage wrote:
José Morango wrote:

I use TakePhotoFromCameraAction to take a picture, then I use the
TCameraComponent to read Qr-Code with the Zxing library.
Qr-Code always works until I take a picture (TakePhotoFromCameraAction),
after taking the photograph I try to read the Qr-Code from TCameraComponent
and gives the error: "java.lang.RuntimeException ..."

An example project that reproduces the issue might help.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

I've created an example the most similar to my project.
The error continues.
After a few more tests, I also read Qr-Code and then I can not take a picture.
One component after initialization does not allow the other to start the camera.

Follow the link to download:

https://www.dropbox.com/s/2bjg5i11j5mwma8/TesteTCamera_ActionList.rar?dl=0


You need to add the Zxing library to the project.
The library is located in the root and in the "libraries" folder.

Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 13, 2017 12:14 PM   in response to: José Morango in response to: José Morango
José Morango wrote:

I've created an example the most similar to my project.

I should have indicated that it should be a simple project to illustrate the issue. Also, your project has references
to code that I do not have (such as TMS components and Winsoft), which are probably not required, but means spending
time to remove them.

Read your original question, and read my answers. At some point in your code I expect that something is attempting to
take control of the camera when something else already has control of it.

Also, reading QR Codes using the ZXing Delphi port is less complex than in your application. I did the same thing a few
months ago at the company where I was working, and it was much more straightforward; there was no need for timers like
in your application.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
José Morango

Posts: 19
Registered: 10/2/14
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 2:16 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
José Morango wrote:

I've created an example the most similar to my project.

I should have indicated that it should be a simple project to illustrate the issue. Also, your project has references
to code that I do not have (such as TMS components and Winsoft), which are probably not required, but means spending
time to remove them.

Read your original question, and read my answers. At some point in your code I expect that something is attempting to
take control of the camera when something else already has control of it.

Also, reading QR Codes using the ZXing Delphi port is less complex than in your application. I did the same thing a few
months ago at the company where I was working, and it was much more straightforward; there was no need for timers like
in your application.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog


I made the project very simple and sorry to have forgotten to take the other references.

Can you add the Zxing Library and test to get the same error?
It happens on the second attempt.
 
I'm also looking for something that does not release the camera,
but I do not understand what it is.

Follow the link to download:
https://www.dropbox.com/s/j4qcmlo0ub65k0f/TesteTCamera_ActionList.rar?dl=0

José Morango

Posts: 19
Registered: 10/2/14
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 2:56 AM   in response to: José Morango in response to: José Morango
I begin to think that it is something in the ZXing Library that does not release the camera and not the components problem.
I only get the error after get the Qr-Code to Tedit.
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 8:56 PM   in response to: José Morango in response to: José Morango
José Morango wrote:

I begin to think that it is something in the ZXing Library that does not release the camera and not the components
problem.

The Zxing library for Delphi has nothing to do with the camera; it's purely image processing.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
José Morango

Posts: 19
Registered: 10/2/14
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 17, 2017 3:31 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
José Morango wrote:

I begin to think that it is something in the ZXing Library that does not release the camera and not the components
problem.

The Zxing library for Delphi has nothing to do with the camera; it's purely image processing.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

But this happens after getting Qr-Code. If you do not get the Qr-Code for tedit it works normally. It only happens after processing the Qr-Code.

E Spelt

Posts: 24
Registered: 12/26/09
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 17, 2017 8:45 AM   in response to: José Morango in response to: José Morango
José Morango wrote:
Dave Nottage wrote:
José Morango wrote:

I begin to think that it is something in the ZXing Library that does not release the camera and not the components
problem.

The Zxing library for Delphi has nothing to do with the camera; it's purely image processing.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

But this happens after getting Qr-Code. If you do not get the Qr-Code for tedit it works normally. It only happens after processing the Qr-Code.


I suspect it happens because the TCameraComponent or the camera in TakePhotoFromCameraAction is still active. When you are done with the TCameraComponent. You need to set the active to false.

Looking at your sample project I notice:

1) you have a 'circulair uses' going on. mainForm creates Form2 which creates mainForm. This is bad design and gives problems.
In your case I would recommend: Auto create both forms. When you are done with the second form just close it. Your main form will appear again. When the application shuts down, the forms gets freed automatically.

2) you have to set the TCameraComponent.Active to false when you have finished used it.
In your case I would it set TCameraComponent.Active := False; in the onClose form Event (if you followed my first suggestion).
When you are done with the TCameraComponent, make sure you set active always to false

Hope it helps,
Edward
José Morango

Posts: 19
Registered: 10/2/14
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 3, 2017 4:08 AM   in response to: E Spelt in response to: E Spelt
E Spelt wrote:
José Morango wrote:
Dave Nottage wrote:
José Morango wrote:

I begin to think that it is something in the ZXing Library that does not release the camera and not the components
problem.

The Zxing library for Delphi has nothing to do with the camera; it's purely image processing.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

But this happens after getting Qr-Code. If you do not get the Qr-Code for tedit it works normally. It only happens after processing the Qr-Code.


I suspect it happens because the TCameraComponent or the camera in TakePhotoFromCameraAction is still active. When you are done with the TCameraComponent. You need to set the active to false.

Looking at your sample project I notice:

1) you have a 'circulair uses' going on. mainForm creates Form2 which creates mainForm. This is bad design and gives problems.
In your case I would recommend: Auto create both forms. When you are done with the second form just close it. Your main form will appear again. When the application shuts down, the forms gets freed automatically.

2) you have to set the TCameraComponent.Active to false when you have finished used it.
In your case I would it set TCameraComponent.Active := False; in the onClose form Event (if you followed my first suggestion).
When you are done with the TCameraComponent, make sure you set active always to false

Hope it helps,
Edward


As you can see in my code (project) I always disable TCamera, or I really can not see in my code where I leave it activated.
I made sure I always turn TCamera.activate = "False" when I do not need camera.

If I am doing "circulair use", how can I improve the way the creation of the "Form" and its release?

I have already done my project with auto creation of "Forms" ("Auto create both forms") and the error persists.

Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: TakePhotoFromCameraAction and next try active TCameraComponent  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 3, 2017 1:48 PM   in response to: José Morango in response to: José Morango
Am 03.04.2017 um 13:08 schrieb José Morango:


As you can see in my code (project) I always disable TCamera, or I really can not see in my code where I leave it activated.
I made sure I always turn TCamera.activate = "False" when I do not need camera.

If I am doing "circulair use", how can I improve the way the creation of the "Form" and its release?

I have already done my project with auto creation of "Forms" ("Auto create both forms") and the error persists.

If form2 is creating mainform then there will be a :=
T>ourMainFormClassName.Create statement somewhere in your code for form2.

Did you search for such a thing already?
If you find one ask yourself why you placed it there and how to get rid
of it. If mainform is auto generated there is a global variable in its
unit which can be accessed from form2 usually (if the unit is in
implementation uses list) and you can call .Show on it if you need to
display it. No need to recreate it.

Greetings

Markus
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02