Using Phonegap Barcode Scanner on Iphone - iphone

I'm trying to add a barcode scanner to a JQM phonegap project for iOS. I have followed the instructions listed, although I'm not 100% sure if I did the first and last steps correctly.
Copy the .h, .cpp and .mm files to the Plugins directory in your
project. You may need to set the compile options for
zxing-all-in-one.cc to turn off optimization.
I directly copied the three files into the plugins folder in xcode. It isn't giving me any errors, but it also isn't working. I have no idea how to do compiler options in xcode, so I haven't done the last step.
Currently my app still runs with no errors and running the scan function opens the camera with the ui for the barcode scanner up. The problem is that it doesn't seem to be either looking for or finding barcodes, it just stays up and does nothing (until you hit cancel, then it displays the cancelled message correctly).
Anyone have any ideas what's wrong or where I should look?

If the camera is turned on and the UI for scanning appears on the screen, then it means you've done everything right. The problem seems to be that the scanner doesn't detect the barcodes.
Be aware that recognizing 1D barcodes ("classical" barcodes) with zxing require an iPhone with autofocus lens (iPhone 4 or iPhone 4S). 1D barcodes are a little tricky to detect with mobile phone lenses, you need proper light and focus ; that's one reason why 2D codes like QR code where invented.
Try generating a QR code with http://zxing.appspot.com/generator/, display it on the screen and try scanning it with your app. If it works then good news, everything is OK, but bad news, your phone is not fit for 1D barcode scanning.

Another explanation for this behaviour are compiler flags. As mentioned on BarcodeScanner wiki, you may need to set the compile options for zxing-all-in-one.cc to turn off optimization.
In XCode4, click on your project, then select your target under Targets, go to Build Phases->Compile Sources, select zxing-all-in-one.cc and enter -O0 (that's dash oh naught) into the Compiler flags column.
That solved it for me.

Related

OpenGL ES sprites no longer render after updating to iOS 7.1

I am using a simple 2D sprite class based on this tutorial to render PNG bitmaps to the screen:
http://www.raywenderlich.com/9743/how-to-create-a-simple-2d-iphone-game-with-opengl-es-2-0-and-glkit-part-1
Everything worked fine on both my iPhone 4S running iOS 6.1 and my iPhone 5S running iOS 7. Since I updated to iOS 7.1, and on my MacBook Air updated to Mavericks and XCode 5.1, sprites no longer appear on the screen (I just get an empty white screen, which is the color I cleared the background to). When I build the app using XCode 5.1 and run on my iPhone 4S again, it still works.
Does anyone know what could be causing this? Has anyone run into this issue? I am having trouble getting to the source of the problem due to my lack of understanding of OpenGL ES among other things. :) My sprite class is exactly the same as the one in the tutorial.
Let me know if more details/code snippets are required.
I'm not even going to look at the sample code since it doesn't sound like it's the same as your current code. (You said 'based on'.) But I'll tell you how to find your problem.
First, clear to something other than white (like red) as a test.
If the screen turns red you at least know that your view and context and open gl in general is working. That knocks out a lot of possible culprits.
Second.. use the debug tools and chances are it will take you right to your problem. You have to run on a tethered device though and not the sim. Run your app...
Click on FPS in the debug navigator. Then click analyze and be patient. It will take a one frame snapshot of whats happening in open gl. It has to do a bunch of stuff to make that happen and it takes about 30 seconds. But then you'll have an interactive thing that shows you the frame and will let you step through processes and see what code is making that happen, and the frame as it draws each element. It's super cool actually. And probably it will show you an error message (in red).
My guess is that it's no longer loading your sprite images. Something probably changed between 6 and 7 or the versions of Xcode or of OSX. In that case the screen is blank because they're not loaded and therefore not being drawn.
EDIT:
I think the analysis will help find your problem. But to offer more possibilities, in my experience when nothing is drawing it's often one of these things:
An overall OpenGL issue - set your clear color to red or blue to test.
Shader didn't compile - always output shader compile errors so you know.
Bad Shader math or logic - use gl_FragColor = vec4(0.0,0.0,1.0,1.0) or some contrasting color to test. Can you see your structures?
Program isn't getting an attribute. Did you remember glEnableVertexAttribArray
Program isn't getting a uniform. Use the Analyze feature above to check the uniform values to make sure they made it to the shader.
(i'll add more if I think of them)
When stuff does

trying to add quartz framework

I'm trying to add quartz framework but when I test if I've added correctly I got the error
quartz not found as:
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1.
I tried:
go to target
expanding and double clicking.
now I got a window opened having linked libraries.
clicking on + sign.
now i got list of all the frameworks but "surprise not the quartzframework only quartzcore type of thing"
so I click on add other and navigate to system-->library-->frameworks and select quartzframework.
click on relative to build product and add successfully.
Now if I try to test if everything is fine I got above error. I also tried to clean all targets close Xcode but getting error.
i also try this link go to project menu-->add to project-->systems-->library-->frameworks-->quartzframework
any suggestions?
Thanks
That folder contains frameworks for OS X; Quartz is not in iOS. Quartz is just a compilation of a few other frameworks, most of which do have alternatives in iOS. PDFKit can be replicated by UIWebView for simple PDF displaying, or CGPDFDocument if you want more advanced control. QuicklookUI is available separately as Quicklook.framework with a few differences.
However, there is no equivalent of Quartz Composer in iOS, even in private frameworks. OpenGLES is pretty much your only option for 3d graphics, but don't expect the iPhone to handle something as complex as a Quartz composition would be.
And the iOS frameworks are located in
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/

IPhone simulator vs. Device issue (open GL)

I am developing an iPhone application using openGl ES 2.0, and after a lot of testing in the simulator I installed the application on my iPhone(3GS) to see how well it preformed. When the app launched it started up fine with no errors, but nothing showed up, however the background was the appropriate color.
Does anybody have any ideas/pointers about what might be causing this issue? If code/details would help just let me know what section of code you would like to see.
Check the constraints on various functions you may use. For example, by default the width and height for glTexImage2D must each be powers of 2 (or powers of 2 plus 2, if you are using a border). There is an extension that allows for non-power-of-two textures, but in my experience this extension is not present or is not completely implemented on at least some devices (i.e. it works for GL_CLAMP_TO_EDGE but not GL_REPEAT).
The Device is strict about case-sensitivity in filenames -- check to make sure that if you are loading Shaders, that the filenames referenced in your code are identical to their actual filesystem names.
Also, if you are in xCode 4, go to your Target Build Phases settings and make sure all of the shaders you use are in Copy Bundle Resources.
Finally, if the shaders appear in 'Compile Sources', you should remove them from there. You'll need to Clean your project and then re-build.

Problem displaying font texture (SDL Xcode 4 project)

The below project of mine works fine with OpenGL on Windows and the Mac but will not work on the iPhone simulator or physical device.
The below link is to an Xcode 4 project containing the usual SDL examples plus an extra one called Rectangles2. I can't get my font characters to appear on the screen - I just keep getting a white rectangle.
Can somebody please have a look and tell me what is wrong with my project?
Please don't be critical of how its coded - I would just like to know what I'm missing to make it work.
Xcode Project
Thanks
I've just been told the problem was my parameter to the glTexImage2D function. The code I borrowed uses some literal values 3 and 4 whatever they are. Anyway, changing these to GL_RGBA has solved my problem.. so I'll have to go and read up on what this function actually does and how it works etc.

Xcode Performance Tool thinks the iPhone simulator has a camera

When I run this code in the Simulator in the debugger or standalone
[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]
it tells me the camera is not available (returns NO), as expected.
However, if I run the same code in the simulator in Performance Tool, it returns YES! My code (which works fine on device) then continues to display the camera view in the simulator. If I attempt to capture an image though, I get a console message
photos can only be captured on HW
Which means that if I want to profile my application on the simulator (wouldn't it be nice if it worked on the device!!) I need to go change the code so that it displays the correct view (i.e. not the camera one!).
This does not, from googling, appear to be a well-known issue. Has anyone else experienced it and/or got a workaround?
The obvious workaround is to add an
#if TARGET_IPHONE_SIMULATOR
But that's just icky. The whole point of doing the isSourceTypeAvailable in the first place is to avoid that sort of thing.