openui5-camera
A UI5 control that renders a live camera preview from the device's camera and hands the app the picture as a base64-encoded PNG when the user taps it.
The control reaches the device's camera through the HTML5 media capture API, renders the live preview in a view as <cam:Camera> and fires a snapshot event when the user clicks or taps the preview. The handler reads the picture from oEvent.getParameter("image") as a base64-encoded PNG string, which the README attaches directly to the src of an Image or posts to a server inside a JSON message. Installing it is not a plain npm dependency: after npm install openui5-camera the built dist/openui5/camera/library-preload.js is copied into the application and registered through a resourceRoots entry under sap.ui5 in the manifest. The README heads the repository with EXPERIMENTAL CODE and calls the code a proof of concept rather than a finished product.
Facts
Where it sits
Who is behind it
In the atlas: maintains 1, contributes to 1@tiagobalmeidamaintainer
Before choosing this
Signals
ActivityQuietRelease and repository quiet for 28 months
Both observable publication channels have been quiet for at least 24 full months. This may be normal for stable software; check whether its current state still fits your use.
What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
As a package
- Where it runs
- does not say
- Distributed through
- does not say
Connections
Custom controls, wrappers and icon fonts packaged for reuse
Framework core: module loader, MVC runtime, binding, routing, theming
Download
Install
npm add openui5-cameraDerived from the package name. No recipe recorded; the README has the configuration.
README
quoted from tiagobalmeida/openui5-camera under Apache-2.0, readOpenUI5-Camera
EXPERIMENTAL CODE
An UI5 control which uses the HTML5 media capture API to access the device's camera. The control renders a live camera preview and can take pictures when the users clicks/taps on it. This a proof of concept, not a finished product. Use at your own risk.
Demo
Please check here
TODO
- Add an optional button instead of clicking on the preview only
- Allow the image format to be configurable
- Allow an easy way to get the actual image pixels for manipulation
- Configurable camera (front-facing vs back-facing)
- Think about video and audio streams
Usage
To use it you must first install this code in your app.
Instalation
- Make sure your app has a package.json at the root. If it does not, do
npm initand follow the prompts. - Do
npm install openui5-cameraat the root of your project. This will pull this code into a subfolder namednode_modules. - Copy file
node_modules\openui5-camera\dist\openui5\camera\library-preload.jsintothirdparty\openui5\camera\library-preload.js(create folders as necessary). - In your manifest, declare a dependency to this control by adding the following inside
sap.ui5:
"resourceRoots": {
"openui5.camera": "./thirdparty/openui5/camera/"
}
- Check
test/demo/manifest.jsonif you're unclear about the previous step.
Usage in your app
- In the view you want to display the camera preview, insert the following:
<cam:Camera
id="idCamera"
width="800"
height="600"
snapshot=".onSnapshot" />
-
Add the following to the same view's namespace declarations:
xmlns:cam="openui5.camera" -
In the corresponding controller, add an event handler. This function will be called everytime the user clicks/taps the preview. It contains the picture in PNG format encoded in base64 (so it is a character string).
onSnapshot: function (oEvent) {
// The image is inside oEvent, on the image parameter,
// let's grab it.
var sSnapshot = oEvent.getParameter("image")});
// Do something with it!
// As you see in the demo, you can attach it directly to a src of an Image.
// Because it is already a text string it is also easy to POST to a server inside a json message.
},
Found a bug? Want to contribute to this project?
- Install node.js (get it from nodejs.org).
- If working behind a proxy, you need to configure it properly (HTTP_PROXY / HTTPS_PROXY / NO_PROXY environment variables)
- Clone the repository and navigate into it
git clone https://github.com/jumpifzero/openui5-camera
cd openui5-camera
- Install all npm dependencies (also installs all bower dependencies)
npm install
- Run
npm startorgruntto lint, build and run a local server (have a look intoGruntfile.jsto see all the tasks).
grunt
- Open a test page in your browser: http://localhost:8080/test/demo/index.html Attention: In Chrome, the camera API is blocked when using http as the protocol. For this reason, you have to either disable web security or setup a self-signed https local server.
Contributing
Contributions are welcomed. Please use a feature branch and don't forget to include your name (alphabetical order) in the list below.
Contributors
- Tiago Almeida - jumpifzero@gmail.com - @tiagobalmeida
@stermi repo openui5-chartjs was also critical as an example, so thanks @stermi and all other UI5Lab contributors :)
History
Others providing
Compare all 15 on the Custom controls and libraries page →- custom-controlscustom-controlsThirteen custom controls for abap2UI5, a signature pad and a scanner that reads several barcodes at once among them, each one an ABAP builder class with a single render( ) method and all of them shipped in a BSP of their own.community org, abapThirteen custom UI5 controls for abap2UI5 appsfrom ABAP
- @abap2ui5/embed-control@abap2ui5/embed-controlA UI5 custom control that runs an abap2UI5 app inside a host UI5 app, with the abap2UI5 frontend loaded from the backend the app talks to.community org, ui5UI5 custom control that runs an abap2UI5 app inside a host appfrom UI5
- ui5-cc-timerbuttonui5-cc-timerbuttonA UI5 control library with TimerButton, an sap.m.Button that delays becoming enabled or visible and shows other text or an icon in the meantime, with the delay set in milliseconds.independent, ui5UI5 control library with a button that delays enabling or showingfrom UI5
- ui5-control-generatorui5-control-generatorA command-line generator that writes UI5 custom controls, in JavaScript or TypeScript, from the html files in a project, with control logic and renderer split into two files by default.independent, ui5Command line generator of UI5 custom controls from htmlfrom UI5
- @marianfoo/ui5-cc-dayjs@marianfoo/ui5-cc-dayjsA UI5 custom control that writes a date to the page through Day.js, with the input format, the output format and any shift of days or months set as control properties.independent, ui5UI5 custom control formatting dates with Day.jsfrom UI5
- ui5-cc-pdfviewerui5-cc-pdfviewerA UI5 custom control that renders a PDF from a base64 data URI with pdfjs-dist, so a file picked in the browser can be shown before it has been uploaded anywhere and has a URL.independent, ui5UI5 custom control rendering a PDF from a base64 data URIfrom UI5
- openui5-passwordopenui5-passwordAn OpenUI5 input control of password type that checks the typed value against length and character-class rules set as properties, and scores password strength in a separate property.independent, ui5OpenUI5 password input with strength scoring and rulesfrom UI5
- openui5-touropenui5-tourAn OpenUI5 control library for a step-by-step guided tour inside a UI5 app, where each TourStep has a title, content, a target control from the view and a placement.independent, ui5OpenUI5 control library for guided app toursfrom UI5
- ui5-lib-visualizationui5-lib-visualizationA UI5 control library that wraps the C3.js charting library as ui5.viz controls (Chart, ChartSeries, ChartDataPoint, ChartAxis, ChartLine, ChartArea and Color) declared in an XML view with data binding.independent, ui5UI5 control library wrapping C3.js charts as ui5.viz controlsfrom UI5
- UI5XUI5XAn OpenUI5 and SAPUI5 library of eight composite controls under the ui5x namespace: skeleton placeholders and a container that swaps them for content, loading wrappers for the responsive and the grid table, an accordion, a copy button, a segmented input and a chat feed.independent, ui5UI5 library of eight composite controls under the ui5x namespacefrom UI5
- ui5-cc-chartui5-cc-chartA UI5 custom control that wraps Chart.js to render a line chart from label and value records, installed as a plain npm dependency with ui5-tooling-modules in ui5.yaml.community org, ui5UI5 custom control wrapping Chart.js for line chartsfrom UI5
- ui5-cc-mdui5-cc-mdA UI5 custom control that renders Markdown, including GitHub-flavoured syntax, to HTML inside an XML view, taking its content from a string, a file path or a model binding.community org, ui5UI5 custom control rendering Markdown to HTMLfrom UI5
- ui5-fontawesome-libui5-fontawesome-libA UI5 library that adds Font Awesome's regular, solid and brand icon sets to the sap-icon:// namespace, addressable from a standard Icon control, for UI5 1.120.33 or later.community org, ui5UI5 library adding Font Awesome icon sets to sap-icon://from UI5
- openui5-paginatoropenui5-paginatorA UI5 custom control that pages through large data in a table, for backends that serve pages over REST rather than OData.independent, ui5A UI5 custom control that pages through large data in a table, for backends that serve pages over REST rather than OData.from UI5
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
History in the atlas
- First seen.
For your agent
- Ref
artifact:tiagobalmeida-openui5-camera- JSON
- /artifacts/tiagobalmeida-openui5-camera.json
- MCP
- Connecting an agent