Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

QR Scanner
Started by Michael W. Aug 12 2015 01:53 PM

368 replies to this topic
release android ios
[TOPIC CONTROLS]
Page 3 of 15 1 2 3 4 5 »
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#51

anil8

[GLOBAL: userInfoPane.html]
anil8
  • Contributor

  • 124 posts
  • Corona SDK

The mechanism you employed to display a message before the Plugin starts and then remove it afterwards.

 

(thinking about it you probably could have used Sergey's new Toast plugin to show the message)



[TOPIC: post.html]
#52

runewinse

[GLOBAL: userInfoPane.html]
runewinse
  • Contributor

  • 484 posts
  • Corona SDK

Ok, sure...

 

The message/removal part is the qrReturn() and onSystemEvent() functions. The rest is stuffing. I just use the native.alert for showing the message. Surely there are more fancy ways of displaying that the QR scanner is about to start, but the auto removal mechanism is the same.

 

I have added an extra variable (waitingForQRScanner) so that the qrReturn() is only called in the event of a return from the scanner and not each time the app gets focus. It's probably not needed though...

local qrscanner = require('plugin.qrscanner')

_W = display.contentWidth
_H = display.contentHeight
_CENTER_X = _W/2
_CENTER_Y = _H/2

-- Forward declarations
local waitingForQRScanner = false
local qrAlert             = nil
local qrText              = nil

-------------------------------------------------------------------------------- QR scanner functionality - START
local function qrReturn()  
  waitingForQRScanner = false
  if (qrAlert ~= nil) then native.cancelAlert(qrAlert) end
end

local function qrListener(message)  
  qrText.text = message
  qrReturn()
end

local function qrButHit()
  waitingForQRScanner = true
  qrAlert = native.showAlert("Info", "Starting QR scanner")
  qrscanner.show(qrListener)
end
-------------------------------------------------------------------------------- QR scanner functionality - START


-------------------------------------------------------------------------------- QR button/text setup - START
local qrButtonRect = display.newRect(_CENTER_X, _CENTER_Y, _W*0.75, _H*0.1)
local qrButtonText = display.newText("Start QR scanner", _CENTER_X, _CENTER_Y)
qrButtonText:setFillColor(0)

local function qrButtonHandler( event )
	if (event.phase == "began") then
    qrButHit()
    return true
  end
end

qrButtonRect:addEventListener( "touch", qrButtonHandler )

qrText = display.newText("Scanned QR code goes here", _CENTER_X, _H*0.7)

-------------------------------------------------------------------------------- QR button/text setup - END



----------------------------------------------------------- Setup applicationResume trigger - START
local function onSystemEvent(event)
  if (event.name == "system" and event.type == "applicationResume" and waitingForQRScanner == true) then
    qrReturn()
  end
end
Runtime:addEventListener( "system", onSystemEvent )
----------------------------------------------------------- Setup applicationResume trigger - END



[TOPIC: post.html]
#53

WarrenW

[GLOBAL: userInfoPane.html]
WarrenW
  • Contributor

  • 830 posts
  • Corona SDK

I still have not received any email to download this. Is that what everyone else gets?



[TOPIC: post.html]
#54

Michael W.

[GLOBAL: userInfoPane.html]
Michael W.
  • Contributor

  • 276 posts
  • Alumni

I still have not received any email to download this. Is that what everyone else gets?

To keep this thread on-topic, I have moved your question and provided an answer here:

 

https://forums.coronalabs.com/topic/58784-login-instructions-email/



[TOPIC: post.html]
#55

ibjones

[GLOBAL: userInfoPane.html]
ibjones
  • Observer

  • 1 posts
  • Corona SDK

Great job on the plugin. It works great on my daughters samsung galaxy phone but I am having an issue with my two other android phones. Both have the same problem and both are running android version 4.1.2. When I press the button to start the scan both phones display the message "This device does not have a camera."

 

Phone 1

droid razr (xt912) -> android version 4.1.2

 

Phone 2 

Lg (Lgl39c) -> android version 4.1.2



[TOPIC: post.html]
#56

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 532 posts
  • Corona Staff

Great job on the plugin. It works great on my daughters samsung galaxy phone but I am having an issue with my two other android phones. Both have the same problem and both are running android version 4.1.2. When I press the button to start the scan both phones display the message "This device does not have a camera.

Thanks! Must be fixed, wait for the plugin to be synced and try again.



[TOPIC: post.html]
#57

tonygod

[GLOBAL: userInfoPane.html]
tonygod
  • Contributor

  • 196 posts
  • Corona SDK

Hello Sergey, this works flawlessly on my BLU phone, but I am seeing the "This device does not have a camera" message on an Amazon Kindle Fire HD 8.9" tablet.  Please note this device only has a front-facing camera -- perhaps it is not sufficient for QR scanning.  media.hasSource( media.Camera) succeeds as well as media.capturePhoto.



[TOPIC: post.html]
#58

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 532 posts
  • Corona Staff

Hello Sergey, this works flawlessly on my BLU phone, but I am seeing the "This device does not have a camera" message on an Amazon Kindle Fire HD 8.9" tablet.  Please note this device only has a front-facing camera -- perhaps it is not sufficient for QR scanning.  media.hasSource( media.Camera) succeeds as well as media.capturePhoto.

Can you please tell me on what Android version it's OS is based on?



[TOPIC: post.html]
#59

tonygod

[GLOBAL: userInfoPane.html]
tonygod
  • Contributor

  • 196 posts
  • Corona SDK

Can you please tell me on what Android version it's OS is based on?

I believe it is 4.0.3



[TOPIC: post.html]
#60

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 532 posts
  • Corona Staff

I believe it is 4.0.3

I've just uploaded a possible fix. Old androids are very tricky when it comes to detecting cameras.
Please try again when you see the plugin has been redownloaded in the simulator.



[TOPIC: post.html]
#61

tonygod

[GLOBAL: userInfoPane.html]
tonygod
  • Contributor

  • 196 posts
  • Corona SDK

I've just uploaded a possible fix. Old androids are very tricky when it comes to detecting cameras.
Please try again when you see the plugin has been redownloaded in the simulator.

 

The camera shows up now, but it is mirrored.  This is probably because it is a front-facing camera.  When I scan a code, it returns with the wrong code, I think because the image is mirrored.  see below.

 

oKbTq6o.png?1



[TOPIC: post.html]
#62

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 532 posts
  • Corona Staff

The camera shows up now, but it is mirrored.  This is probably because it is a front-facing camera.  When I scan a code, it returns with the wrong code, I think because the image is mirrored.  see below.

Please try to scan this code and see if it reads correctly. I've mirrored it myself.
Error in scanning can be due to poor light and camera quality as well.
 

Attached Files



[TOPIC: post.html]
#63

tonygod

[GLOBAL: userInfoPane.html]
tonygod
  • Contributor

  • 196 posts
  • Corona SDK

Please try to scan this code and see if it reads correctly. I've mirrored it myself.
Error in scanning can be due to poor light and camera quality as well.
 

That one works perfectly.



[TOPIC: post.html]
#64

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 532 posts
  • Corona Staff

That one works perfectly.

There is a problem. I do have a piece of code that compensates for mirroring front facing cameras, and if your device still shows up mirrored, it could be the problem of the device firmware. Early Android 4 builds have quite a few camera related bugs.
If I touch this piece of code, other Android devices might turn mirrored.

If I had your device on hands, I could tell for sure.

Can you install fresh custom rom on this device and see if it is still mirrored?



[TOPIC: post.html]
#65

tonygod

[GLOBAL: userInfoPane.html]
tonygod
  • Contributor

  • 196 posts
  • Corona SDK

There is a problem. I do have a piece of code that compensates for mirroring front facing cameras, and if your device still shows up mirrored, it could be the problem of the device firmware. Early Android 4 builds have quite a few camera related bugs.
If I touch this piece of code, other Android devices might turn mirrored.

If I had your device on hands, I could tell for sure.

Can you install fresh custom rom on this device and see if it is still mirrored?

 

I can appreciate the situation re: old Android versions.  This tablet model isn't worth the trouble.  I will eventually apply a custom rom and make it work better, but right now I am using it to test and don't want to risk messing it up until I'm done testing.



[TOPIC: post.html]
#66

guy.stockwell

[GLOBAL: userInfoPane.html]
guy.stockwell
  • Contributor

  • 100 posts
  • Corona SDK

likely a stupid question, but I am getting the error "plugin.scanner library is not available on this platform" with the sample project.



[TOPIC: post.html]
#67

guy.stockwell

[GLOBAL: userInfoPane.html]
guy.stockwell
  • Contributor

  • 100 posts
  • Corona SDK

nvm... Now for maybe a less stupid question... How can you replace the overlay?



[TOPIC: post.html]
#68

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 532 posts
  • Corona Staff

likely a stupid question, but I am getting the error "plugin.scanner library is not available on this platform" with the sample project.

It's "plugin.qrscanner", not "plugin.scanner".



[TOPIC: post.html]
#69

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 532 posts
  • Corona Staff

nvm... Now for maybe a less stupid question... How can you replace the overlay?

You can't. At some point later I will make it more customizable, no time for it right now.



[TOPIC: post.html]
#70

guy.stockwell

[GLOBAL: userInfoPane.html]
guy.stockwell
  • Contributor

  • 100 posts
  • Corona SDK

Understand. As an option it would be great if there was an alternative overlay that could be selected via a parameter that has a dotted rectangle (landscape) instead of a square to facilitate rectangular barcodes like vin barcodes on a car etc.Thanks for your contribution, this actually saves me form having to subscribe to the enterprise edition!



[TOPIC: post.html]
#71

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

When trying to build the APK I get the following error:

 

qr.jpg



[TOPIC: post.html]
#72

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 532 posts
  • Corona Staff

When trying to build the APK I get the following error:

You didn't get the plugin from Corona Store to your account. https://store.coronalabs.com/plugin/qr-scanner



[TOPIC: post.html]
#73

rodrigopalmeira

[GLOBAL: userInfoPane.html]
rodrigopalmeira
  • Enthusiast

  • 50 posts
  • Corona SDK

@Lerg

 

Its occurring an error.

 

I've already get the plugin at the store and checked the code.

 

Check it: 

 

Captura_de_Tela_2015_10_08_s_14_11_02.pn



[TOPIC: post.html]
#74

rodrigopalmeira

[GLOBAL: userInfoPane.html]
rodrigopalmeira
  • Enthusiast

  • 50 posts
  • Corona SDK

@Lerg

 

Its occurring an error.

 

I've already get the plugin at the store and checked the code.

 

Check it: 

 

Captura_de_Tela_2015_10_08_s_14_11_02.pn



[TOPIC: post.html]
#75

DEVEL0PER

[GLOBAL: userInfoPane.html]
DEVEL0PER
  • Observer

  • 14 posts
  • Corona SDK

Hello, I'm rather new to Corona, would you be able to clarify what is returned by the plugin (If the QR code is a website link, is that what's returned, and if the QR code is a string, would a string be returned)?

Thanks.




[topic_controls]
Page 3 of 15 1 2 3 4 5 »
 
[/topic_controls]

Also tagged with one or more of these keywords: release, android, ios