Applet to Capture Images from a WebCam - java

I'm trying to create an Applet that will capture images from my Webcam.
I saw an sample in this thread but the imports don't work in my class. They weren't recognized.
I'm a newbie with Java, so, what i'm doing wrong ?

You must include the required external libraries (.jar) in your project in order for the compiler to find its imports.
In the answer you refer to, JavaCV is the API of choice, and also in the answer is a tutorial on configuring JavaCV for use.

In Webcam Capture project source code you can find webcam applet example and the working demo available here. This example does not require any additional JARs since it's shaded while the build. Shading is a process which packs all classes, from all dependent JARs, together, in only one file, referred then as shaded JAR. If you share all JARs you don;t have to build classpath since all imports are packed together.
From the code perspective there is no difference from using webcam API provided within Webcam Capture project in JFrame or JApplet. It contains WebcamPanel class which can be easily used to display image from camera in real time. For more details please check other examples.
The one important think you have to do, is to sigh your applet. This is required operation if you like to access host hardware. Without signing you would have to specify set of appropriate permissions, but I never did this, since, from my perspective JAR shading and signing with Maven a way easier.

Related

Plugins to add features to java

I'm working on a project that requires to add some features to an existing java application using Netbeans. After searching the net, i founded that I should use "plugins". I didn't hear of plugins before.
I have a java application that I should download it from the net, then lets say I have to add a button, when clicked, calls a function that is written in some class in the application. In other words I want to make a new class that is able to access the classes and functions that are written in this application.
What I understood from searching the net is that:
-In the downloaded project's folder there is a folder named plugins.
-This folder contains zip files that contains classes and other stuff.
-I should make a plugin and add it to this folder in order to add a specific feature to the application.
That's what I know, if there is something wrong in what I said, I'll be thankful to correct to me.
Now, my question is that I want a link or website that can teach me how to create and add a plugin to an existing java application. Thank you :)
That entirely depends on the java application you're talking about. Not every application has a Plugins functionality. And not every Java Application uses the same Plugin API. The best bet is to go to the site of the App you're talking about and see if they offer a documentation about their Plugin API.

Use Processing PDE files within Java?

I have a working Java code that I would like to visualize using processing. I also found the tutorial on how to include processing within eclipse and am also already able to create a canvas, etc.
What I want to do now is to actually do the visualization. I found a nice project that is exactly what I need. However, the author provides PDE files.
How can I include PDE files in my java project? Is that even possible?
The PDE files that are available in that project are simply text files. You can either use them in your code directly, or better yet, try to understand what they're doing and adapt the code to your own purposes.
But to answer your question, you don't include PDE files in a Java project. You included the Processing library jars on your classpath, which give you access to things like the PApplet class. Then you can include a PApplet (which is just like a Processing sketch, in fact a Processing sketch is a PApplet) in your Java application and pass it whatever information you want.
More info here: http://processing.org/tutorials/eclipse/

Android PDF Viewer Library or muPDF library tutorials

I'm trying to read pdf files in my android application. I don't want to use the default pdf reader and simply open a new intent because I need my own GUI, and want to use the first page as a cover. Therefore I need to make my own pdf reader. I did some research and came across muPDF and Android PDF Viewer Library.
I tried to follow tutorial to implement Android PDF Viewer Library, from the github description. But the problem is that it loads pdf file forever. Do I need to do something else than just the steps in the description?
I can't find any tutorials for the muPDF library, are there any? How to implement it?
If there is no useful answer for the previous two questions, are there any good pdf library out there with tutorials and good documentation?
Thank you, hopefully, I will be able to solve my problem
MuPDF is a very good library, you can definitely use it. If you need a complete example of Android app using MuPDF, I suggest you to take a look at this customizable magazine app on Github.
first of all, if you want to use MUPDF inside an existing android app project you can follow the guide you find at this link (all credits go to the author, I didn't write this).
I am trying as well to integrate a very simple PDF reading/printing solution inside my app and i am struggling to strip down/simplify the MuPdf application demo you get by following that guide. I already managed (somehow) to remove annotation and file-picking features, but i would really need some help as well to get all the job done. There's really a lot of stuff and absolutely no documentation about this. I am simply trying to read the code and figure out what is needed and what is not, removing features one by one and being driven by the errors you get in catlog.
Also, as we both (if I understood correctly your needs) need just the PDF rendering features, would be great if someone points out how to (if possible) disable some of the unnecessary features built in the MuPDF library when building it from source (as DjVu support, just as an example).
Hope this helps, even if it is not a real answer to your question.
This is how I succeeded in building a MuPDF lib on windows with Cygwin, android-ndk
Download MuPDF 1.3 Source from https://code.google.com/p/mupdf/downloads/list
unzip to folder c:/mupdf-1.3-source
Install Cygwin:
Download and run Run setup-x86.exe from http://cygwin.com/install.html
when installing cygwin, make sure you selected make packages and C++ compilers
Make generate. open cygwin terminal, run
cd /cygdrive/
cd c/mupdf-1.3-source
make generate
Install android-ndk:
download android-ndk-r9d-windows-x86.zip and unzip it to
c:/android-ndk-r9d
Build mupdf lib: on windows cmd console:
preparation:
cd c:/mupdf-1.3-source/platform/android
copy local.properties.sample local.properties
edit local.properties, uncomment
#sdk.dir=C:\\Program Files (x86)\\Android\\android-sdk
and change to
sdk.dir=REAL andforid-sdk Folder
build:
while still on c:/mupdf-1.3-source/platform/android, run:
/android-ndk-r9d/ndk-build
Upon the completion of the build, a folder named libs will be created under
c:/mupdf-1.3-source/platform/android
Create android apk.
Open eclipse, create a new android project from existing code, browse to c:/mupdf-1.3-source/platform/android, now you can create a mupdf apk.
Starting with Android 5.0 you can also use Android's internal PDF renderer and for manipulating PDF you can always use iTextg - just some alternatives for the future.
This SO answer lists some steps on how to rip essential pieces from the MuPDF Java sample app to one's own.
Preferably, I'd like to have a "ready to use" Java library I could attach to as a dependency. Is JNI preventing this or is it simply that no-one's gotten up to doing one?
Well, jmupdf is there (mentioned in this duplicate) but that lists Windows and Linux (not specifically Android) as the tested platforms. It seems desktop and dead to me (no changes in 12 months). At least compared to the vibrance of MuPDF itself.

Making a redistributable component or library for Android

I'm just starting out on Android and Java programming, coming in from a C++ background. I was wondering - whats the best way to go about making a library/UI widget/component that I can license to third-party developers?
In C++ I'd ship the customers my headers and *.a files, but I don't know the equivalent in Java.
Are there any good resources or links about this, maybe even from general Java development standpoint.
you can define activities/services that are available for any other application running on android:
"A central feature of Android is that one application can make use of elements of other applications (provided those applications permit it). For example, if your application needs to display a scrolling list of images and another application has developed a suitable scroller and made it available to others, you can call upon that scroller to do the work, rather than develop your own. "
http://developer.android.com/guide/topics/fundamentals.html
Activities and services have some use but there is a whole class of functionality (fancy table viewer for sql) that isn't covered. You can do jars but I don't think you can have android resources in that file. The work around would be to have a Jar and require the user to copy and paste some text into the apps resource directory. You can look at the admob.com android SDK for an example of this.
Not sure about how Android handles this, but the typical distribution of Java code is a .jar file. A .jar is basically a zip file containing all of the compiled .class files in a Java project. There might also be resource/text/etc. files within the .jar. There is no concept of a header file in Java, so all you need are the .class files, and possibly a manifest file to provide some additional meta info about the .jar.
http://java.sun.com/docs/books/tutorial/deployment/jar/
(This is just a general Java answer, it may or may not apply to Android)

Flex Compiler Api: Adding images in Java

I have a very specific question.
I want to compile an ActionScript project within Java in-memory with the help of the Flex Compiler API ( http://livedocs.adobe.com/flex/3/compilerAPI_flex3.pdf ).
My last problem is to add images (jpg, png) that are embedded in the project to the compiler. I donĀ“t see a possibility to do this in-memory and my attempt to add them from disk was also unsuccessful.
Hope someone has a good hint for me.
Greets, Konsumierer
Invoking the flex compiler from java shouldn't be any different from invoking it from the eclipse plugin. I suppose you have the project located somewhere on the filesystem, so I suppose if the images are in the correct relative path, they should be embedded. How do you embed them, actually?
Another option is, in case when you use them in web-environment (and not AIR), to just write a relative server path to the image. For instance - the .swf is in /, you can poing the image to /images/myimage.jpg, and it will work.

Categories

Resources