Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port "capture" interface into this library from main spectral-workbench project #56

Closed
jywarren opened this issue Nov 13, 2018 · 20 comments

Comments

@jywarren
Copy link
Member

The live Capture interface is a great thing to bring into here -- https://spectralworkbench.org/capture

https://github.com/publiclab/spectral-workbench/blob/main/app/views/capture/_capture.html.erb and other files in that directory are the HTML portion.

The JavaScript is in https://github.com/publiclab/spectral-workbench/blob/main/app/assets/javascripts/capture.js

The first attempt, we can just copy that whole file over, and have it appear locally in /src/.

We can consolidate the HTML files into a single static file in https://github.com/publiclab/spectral-workbench.js/tree/main/examples/capture.html and make sure it's pointed at capture.js, and add any necessary dependencies to our package.json file, installing them via npm.

Once we get it all running, we can start doing some awesome things like getting it running on a Raspberry Pi! See this code for reference: https://github.com/publiclab/infragram/blob/f5f62ce483fbc88823de96f5c87d160228c0a764/pi/index.html#L189-L191

We'd love help with this one! A lot of moving parts, but a fun one :-)

@jywarren
Copy link
Member Author

I think this would do to get a Pi running:

var piImage = new Image();
$W.getCrossSection = function() {
  $W.ctx.drawImage(piImage, 0, -$W.sample_start_row);
  piImage.src = "http://pi.local/cam/cam_pic.php?time=" + new Date().getTime(); 
}

This could be seriously improved by getting the preview window working. But it'll do OK for starters. I think the images could be drawn to the <video> element too... but all this is a follow-up issue, don't worry about this just yet.

@jywarren
Copy link
Member Author

OK, I've done a very minimal initial implementation here: #57

This needs a good bit of work, but is successfully getting video from the webcam and graphing.

@jywarren
Copy link
Member Author

It still needs debugging, as well as better separation of basic UI from the integration with the parent server Rails code. Ideally the specific interface connections would be set up via a more standardized set of HTML elements with unique IDs, which would be bound to abstracted features of the capture code. Right now, it's all munged together!

@jywarren
Copy link
Member Author

But an initial step could be to comment out server-specific code and connect it up for us on the Raspberry Pi, and stand-alone in github pages.

@jywarren
Copy link
Member Author

We'll also want this code to produce data in the formats described in https://github.com/publiclab/spectral-workbench.js#usage

@Dhiraj240
Copy link
Member

Dhiraj240 commented Jan 24, 2019

@jywarren I would like to initiate with this work. Can i reserve this project for GSOC 2019 ?
1.If yes then i will first solve some issues and discuss as what specific optimization can be done over it.
2.I have my own raspberry pi 3 and would love to implement it.
3.I have researched about this project and spent my whole day over it, but i am curious about how much accurate is the wavelength data that we are getting as per the graphical details ?
Instead we could use Convolution Neural Networks model which is using deep learning approach for accuracy (if you agree to it).
I am Microsoft Student Partner where i got subscription of Data Science and other courses where i want to use the knowledge of my recent course here.
4.The required data can be produced in a .csv format or other based on the user requirement since it is going to be a standalone application we can provide such an option only after i implement the required approach.
5.So at first should i start making UI design and do some frontend for this repository and start pushing it over here.
6.I guess you have copied the required HTML and Javascript files.
7.Also i want to eradicate the use of upstream Ruby server and want to build it from scratch using Node.js as backend and React.js plus Material UIas frontend.
8.At first the frontend will be deployed on github pages.

I need a green flag from your side to get started before GSOC the frontend will be ready and will be deployed on github pages.

@jywarren
Copy link
Member Author

Hi @Dhiraj240! Thanks for your interest! We don't really reserve projects, but you are very welcome to indicate this as the subject of your GSoC proposal, and that would be great!

I think there are some proposals for neural network or machine learning models, and i think there is some potential for this, but I think perhaps it makes sense for such ideas to be implemented in parallel as swap-in alternatives for existing features, such as the linear calibration we currently use. That way people could mix and match, and the substantial code that might go into such a model could be isolated from the main codebase in a modular way. But I like the idea - as do I like the idea of using machine learning to match spectra, or identify features, perhaps. I'd also recommend opening a separate issue for this and linking in related ideas from publiclab/spectral-workbench#399, publiclab/plots2#4660, and potentially some of the ideas from https://publiclab.org/notes/warren/01-02-2019/brainstorming-for-summer-of-code-2019 (where i recommend you leave a comment about your ideas if you haven't already!)

For the camera integration, yes, I've done a crude initial move of the code, but SpectralWorkbench.org is not running this capture code yet, and it'd require some cleanup and integration work to get it to be included over there. Worthwhile! And the most related to this issue topic.

For the Ruby server, I don't think we're likely to port the entire system, to tell the truth; the code is substantial enough that I would prefer to think about ways to move some more of the functionality into client-side javascript, while keeping the data storage in the back-end Ruby system. One thing that could be an important step towards shifting Ruby code into JS, however, would be to formalize, document, and write tests for the API that is required to provide data to the client-side code. Right now it's spread among a set of different calls that aren't very consistent and most do not have tests. Opening a separate issue for this kind of project, like standardize, document, and write tests for JavaScript API on the parent Ruby project would be very welcome, and might also enable alternative clients to connect through the resulting standard APIs.

Thanks for your great energy!

@jywarren
Copy link
Member Author

Also interesting! #75

@Dhiraj240
Copy link
Member

Hmm. Things look more clearer to me.But right now i am confused as from where should i start ?
Should i be working on connecting raspberry pi as suggested above.

@jywarren
Copy link
Member Author

jywarren commented Jan 28, 2019 via email

@Dhiraj240
Copy link
Member

Okay, things seem clearer now !! i will start working over it.I had a long gap since i joined this organisation and now i got something to prove.
Thank You Sir !! 😄

@jywarren
Copy link
Member Author

jywarren commented Jan 28, 2019 via email

@jywarren
Copy link
Member Author

jywarren commented Jan 28, 2019 via email

@Dhiraj240
Copy link
Member

@jywarren I have started refracting the capture.js code file. I will submit my PR by tomorrow, should i send the PR without getting assigned.
If not then assign this issue and #75 to me. After a hard time i configured my Pi. 😄

@jywarren
Copy link
Member Author

jywarren commented Feb 28, 2019 via email

@sidntrivedi012
Copy link
Member

@jywarren Have you completed the porting of the javascript part of SWB in #57 ?

@jywarren
Copy link
Member Author

jywarren commented Apr 8, 2019

No, i haven't!

@sidntrivedi012
Copy link
Member

Ok, just wanted to confirm. Thanks 🙂

@jywarren jywarren pinned this issue Apr 16, 2019
@jywarren
Copy link
Member Author

jywarren commented Jun 11, 2019

Hi @sidntrivedi012 just copying in helpful links from the Open Call!

spectralworkbench.org - spectralworkbench.org/capture

@jywarren
Copy link
Member Author

I believe this is largely complete in #175 !!!

@jywarren jywarren unpinned this issue Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants