I am new to the world of Web Developing, i am currently using Ruby on Rails to code my webpages.
Here is the problem i am facing right now.
I am trying to make a webapp (using ruby on rails) in which the user must submit an Image(i am using CarrierWave for this) and the program its suppose to do some image processing, recognized objects and count them, so for this task i made a python script which do this automatically(using OpenCV). My problem is that the python script must return a new image which has the objects of interest in rectangles, and then i must store it in the dabase.
Currently i am returning in console where my objects are in the image, and displaying the new image, but i am not able to return the image as an array so that ruby framework can process it and upload it.
A simple view at how i am doing this
In the example1 i am recognizing oranges in the trees.
If anyone can help me or have an idea at how to do it, maybe a different approach could work. I am new in this, i have researched everywhere with no goods results. I didn't want to pose any code because i dont know which part is useful or not. (sorry for my bad english, i am not use to it completely)
To save an image locally into python you need to make an Image object and then save it to a given path.
my_image= Image("simplecv")
my_image.save("my-image.png") # in the current working directory
or to a path :
my_image.save("path/to/img.png")
You can then re-load those files with another language and store them in a database.
More examples on :
http://tutorial.simplecv.org/en/latest/examples/basics.html
Related
Forgive me if I've left anything out or goofed up formatting conventions; this is my first time posting on this sort of forum.
So I've got a Nikon D5600 that I'm using as part of an (extremely basic) image analysis setup. I'd like to be able to use images from it without having to manually transfer the files over each time I run a test, but I've had some trouble getting access to the files.
To be clear, I don't want to capture screenshots of a video; I understand that this is possible, but the resolution is about 1/3 smaller in video, which is a bit of an issue for my application.
So, when I was 6 hours more naive, I plugged in the camera via USB to my (Windows 10) desktop, tried calling the image using the exact (well, I did change the slashes out) file path windows gave me in the properties screen:
img = cv2.imread("This PC/D5600/Removable storage/DCIM/314D5600/CFW_0031.jpg")
That didn't work.
I checked that the command I was using wasn't the issue by copying the picture to another drive:
img = cv2.imread("D:/CFW_0031.jpg")
That worked.
So I think, and think is a bold claim here, that it's something to do with the "This PC" bit of the path. I've read some old (circa 2009) posts about MTP and such things, but I'm honestly not sure if that's even what this camera uses, or how to get started with that if it is in fact the correct protocol.
I've also tried using pygrabber (I believe it's a wrapper of direct show, though my terminology may be wrong) to control the camera via python, but that also didn't work, although I did manage to control my webcam, which was interesting.
Finally, I attempted to set the assign a letter drive to the camera, but found that the camera wasn't in the manager's list of discs. It's entirely possible I just did this method wrong, but I don't quite see how.
Edit regarding comment from Cristoph
-I just need to be able to use the image files in python, probably with opencv. I suppose that counts as reading them?
-I've attached a screenshot of what the "This PC" location looks like in the file explorer. The camera shows up under devices and drives, but doesn't have a drive letter.
I have a requirement involving making a large pptx file with loads of charts, images and tables dynamic. This pptx has default styles. Is there any library or method to make a template so that I can insert the dynamic parts. Like docxtpl library allows us to input a dict and generate a docx file.
Thanks.
You can try the following python modules:
https://pypi.org/project/template-pptx-jinja/
https://pypi.org/project/pptx-template-simple/
https://pypi.org/project/python-pptx-templater/
With the first one, the example they show, it works fine, but im having trouble applying it in another custom ppt.. keep getting "Unepexpected end of template".
The third one didint work for me though, maybe you have more luck.. and now i will try the second one.
I'm not sure I understand your problem...
python-pptx (a tag you've used) is the fundamental programmable way to build a presentation - whether from a "template presentation or not.)
I hope nobody will mind me advertising my md2pptx open source project for taking Markdown and images and making a presentation.
However, I think md2pptx doesn't help you unless you have a way of turning graphs into eg PNG files - and I suspect that's not what you want.
https://gyazo.com/4472adaefcd169a548253d6101041af8
Was recently making a bot to automatically post an "ad" to a site when launched , however i do need pictures and i researched ways to upload pictures all i could find was :Imagepath=os.path.abspath('.\folder1\subfolder2\file1.jpg') driver.find_element_by_id("ImageUploadButton").clear() driver.find_element_by_id("ImageUploadButton").send_keys(Imagepath) and me being new to python or coding in general I have no idea what ".\folder1\subfolder2\file1.jpg" accesses
Make sure you have your actual pathname put in there instead of writing '\folder1\subfolder2\file1.jpg' - that looks like it's just placeholder stuff that the person who wrote the sample code you got put in there to stand in for your actual path.
So if the image you want to upload is in \Volumes\username\bob\Desktop\ and it's called cats.jpg, you need to put '.\Volumes\username\bob\Desktop\cats.jpg' in where '.\folder1\subfolder2\file.jpg' is right now.
Hi Everyone Ive hit a road block in sql. Its the dreaded storing images in sql database. Apparently the solution to this is to store image in a file system. Does anyone know any book or video tutorial that teaches this I cant seem to find any in the web. Im using My Sql and Python to learn how to work with images. I cant find any examples in the web.
Store the image as a file, and store the path of the file in the database.
The fact that the file is an image is irrelevant. If you want a more specific answer, you will need to ask a more specific question. Also, please edit your title so that it corresponds to the question.
I'm having a set of Python scripts that process the photos. What I would like is to be able to create some kind of flash-presentation out of those images.
Is there any package or 'framework' that would help to do this?
I don't know of any Python-specific solutions but there are multiple tools to handle this:
You can create a flash file with dummy pictures which you then replace using mtasc, swfmill, SWF Tools or similar. This way means lots of trouble but allows you to create a dynamic flash file.
If you don't need dynamic content, though, you're better off creating a video with ffmpeg. It can create videos out of multiple images, so if you're somehow able to render the frames you want in the presentation, you could use ffmpeg to make a video out of it.
If you only want charts, use SWF Charts.
You could use external languages that have a library for creating flash files.
And finally there was another script language that could be compiled into several other languages, where swf waas one of the targets, but I can't remember its name right now.
You should generate a formated list with the data to your photos, path and what else you need in your presentation.
That data you load into a SWF, where your presentation happens.
Like that you can let python do what it does and flash what flash does best.
You might find allready made solutions for flash galleries / slideshows. http://airtightinteractive.com/simpleviewer/ is a famous one. You can load your custom xml in it.
Check out Ming, it seems to have Python bindings.
Ming is powerful but you might not find it pythonic to work with.
I prefer Haxe for Flash work. (It's the successor of MTASC)