Remove this ad

Lead

Feb 2 16 5:24 PM

Tags : :

PROBLEM
Github is a great way to organise an open source project. However, when sharing 3D models rather than code a key advantage is lost. Github cannont highlight speicfic changes to models in the same way it highlights changes to lines of code. Therefoer the only record of what changes are made are in the commit history; and this is subject to human error. Whatsmore it becomes very hard to merge changes, even if the changes are to seperate parts of the model. 

CHALLENGE
Blender already has good data structure. Meshes, objects, materials etc. all have unique names and can be imported between blender files. The "Append" option allows all the data blocks of a .blend file to be browsed in a logical file structue. The challenge is to make this readable by GitHub so it can highlight changes in the same way it highlights changes to lines of code within files. 

REQUIREMENTS
1. Github must be able to highlight changes to .blend files
  • See problem section
2. The solution must work across Windows, Mac and Linux.
  • So no one is =10ptprevented from collaborating due to their operating system. 
3. The solution must be licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
  • To allow the solution to be used across all future Open Bionics development and any other collaborative 3D modelling projects. 
SUGGESTED BRIEF
Blender supports "Add-ons" and Github supports "Integrations". Potentially these features can be leveraged to provide a solution. Github has recently added the capability to view STL files so hopefully a similar path can be followed for .blend files. 

Last Edited By: JonathanRaines Feb 2 16 5:27 PM. Edited 1 time

Quote    Reply   
Remove this ad
Remove this ad

#2 [url]

Feb 3 16 1:47 PM

Thanks Jaundice, 

These look like the best options for now. The linking vs. appending does look good but it's more suited to traditional uses of blender, animations. A character can be imported into multiple scenes and updated across all scenes easily. We could apply a similar principle to common components such as actuators etc. However, I'll often have several objects in a model that I'll want to be able to edit in the same file. This isn't possible if they're mesh is linked to a separate resource file. 

The blendgit plugin is a promising start but doesn't appear to support branching and merging. 

Quote    Reply   

#3 [url]

Feb 3 16 2:23 PM

Just found this: https://svn.blender.org/svnroot/bf-blender/trunk/blender/doc/blender_file_format/ I wonder if it could be combined with blendgit to add comments about changes to the .blend DNA, though I am not 100% sure what is actually in the DNA..

update: I had a quick play with it but couldnt really get it to work. My understanding is that BlendFileDnaExporter_25.py will tell you the file structure that a version of blender uses whereas BlendFileReader.py will tell you about the actual blocks in a .blend file. If you know the blocks and their location/length you could do a hash (e.g MD5) on each blocks' data which might mean you could track changes of each block. This assumes that blender doesn't make non functional changes to those blocks between saves. If a block has a pointer to another block that moves you would see unwarranted changes, if it is referenced as a name instead, you shouldn't see unwarranted changes.

update 2: I implemented a .blend file parser following the spec on the blender svn. A blend file has a _lot_ of blocks :)
Below are the last few from the Right Hand file, unfortunately I can't  see any of the hand component names yet. They would be more useful as identifiers. Code here: https://github.com/jaundice/ByteFarm.OpenBionics.Contrib.BlenderInfo 

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923537064
SDNAIndex:448
Count:4
DataHash:15-6A-17-39-53-8F-A8-97-54-33-14-3D-1B-8F-74-25

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016922745448
SDNAIndex:457
Count:1
DataHash:E0-DF-44-89-72-E1-22-69-15-EE-FD-DE-C7-BC-8B-51

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923153896
SDNAIndex:450
Count:1
DataHash:55-4C-1F-76-DF-70-AE-55-3B-CC-20-C1-CA-93-A9-B4

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923538344
SDNAIndex:448
Count:4
DataHash:31-F5-04-A3-41-F4-3C-52-60-35-09-1B-7E-91-4D-7E

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016922738872
SDNAIndex:457
Count:1
DataHash:22-93-1A-2E-DC-B7-01-9B-A6-10-8B-60-98-55-02-6A

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923141896
SDNAIndex:450
Count:1
DataHash:EF-55-5D-8C-4A-BC-C5-61-52-6E-2F-7B-4A-51-6E-7D

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923536872
SDNAIndex:448
Count:4
DataHash:31-F5-04-A3-41-F4-3C-52-60-35-09-1B-7E-91-4D-7E

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016922747640
SDNAIndex:457
Count:1
DataHash:F0-36-47-41-95-17-85-3A-D6-4D-13-7E-C3-0D-96-B8

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923162696
SDNAIndex:450
Count:1
DataHash:C6-EC-DA-79-EC-49-54-35-41-CA-6F-A8-AB-2C-39-40

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923534504
SDNAIndex:448
Count:4
DataHash:31-F5-04-A3-41-F4-3C-52-60-35-09-1B-7E-91-4D-7E

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016922743256
SDNAIndex:457
Count:1
DataHash:BE-D3-83-24-20-A6-B5-58-7F-B1-F5-60-88-39-2D-B6

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923154296
SDNAIndex:450
Count:1
DataHash:A0-95-7C-92-87-6A-3F-9E-CE-93-4D-1E-50-39-EA-88

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923536936
SDNAIndex:448
Count:4
DataHash:31-F5-04-A3-41-F4-3C-52-60-35-09-1B-7E-91-4D-7E

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016922752024
SDNAIndex:457
Count:1
DataHash:9A-D5-18-37-E7-54-13-01-A4-BB-3E-39-2D-86-52-1F

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923159096
SDNAIndex:450
Count:1
DataHash:2C-AE-F2-1C-D5-2E-D4-C9-ED-72-9A-4F-15-E6-92-2F

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923537128
SDNAIndex:448
Count:4
DataHash:31-F5-04-A3-41-F4-3C-52-60-35-09-1B-7E-91-4D-7E

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016922749832
SDNAIndex:457
Count:1
DataHash:EB-1A-B8-D5-65-09-CD-13-8B-02-1D-5A-EE-D2-FE-05

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923140696
SDNAIndex:450
Count:1
DataHash:40-10-8E-72-A0-88-07-36-DF-A7-F0-B2-16-E7-99-CF

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923537000
SDNAIndex:448
Count:4
DataHash:15-6A-17-39-53-8F-A8-97-54-33-14-3D-1B-8F-74-25

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016927466104
SDNAIndex:457
Count:1
DataHash:1B-EE-CB-9D-21-76-12-78-F5-97-22-A1-6D-C3-04-92

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923141496
SDNAIndex:450
Count:1
DataHash:3B-C1-7F-58-73-D2-88-BD-4C-CC-55-F5-13-75-97-16

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923535464
SDNAIndex:448
Count:4
DataHash:31-F5-04-A3-41-F4-3C-52-60-35-09-1B-7E-91-4D-7E

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016927474872
SDNAIndex:457
Count:1
DataHash:E9-81-21-4B-77-6E-FE-43-40-C1-3A-BE-7F-D8-09-02

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923139896
SDNAIndex:450
Count:1
DataHash:B3-54-C9-37-DE-FB-99-20-DA-F3-06-C2-D1-11-ED-37

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923537192
SDNAIndex:448
Count:4
DataHash:31-F5-04-A3-41-F4-3C-52-60-35-09-1B-7E-91-4D-7E

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016927457336
SDNAIndex:457
Count:1
DataHash:BC-36-51-40-21-C7-82-05-4A-F6-B4-6E-C5-BD-F7-79

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923140296
SDNAIndex:450
Count:1
DataHash:B2-F0-D1-AA-6C-74-27-20-0B-38-D3-9C-B7-B1-AF-C6

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923535528
SDNAIndex:448
Count:4
DataHash:15-6A-17-39-53-8F-A8-97-54-33-14-3D-1B-8F-74-25

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016927470488
SDNAIndex:457
Count:1
DataHash:82-5A-44-50-8C-9E-DD-35-65-3F-11-02-14-7B-4A-2B

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923159496
SDNAIndex:450
Count:1
DataHash:7A-AE-C0-9A-AB-37-D6-66-C0-FD-03-AC-F2-6D-B8-E5

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923534760
SDNAIndex:448
Count:4
DataHash:15-6A-17-39-53-8F-A8-97-54-33-14-3D-1B-8F-74-25

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016927459528
SDNAIndex:457
Count:1
DataHash:9F-27-52-F6-7F-D9-4D-39-FA-0D-47-64-6C-A9-3E-82

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923159896
SDNAIndex:450
Count:1
DataHash:BD-64-17-27-CA-23-59-3E-C5-2E-D3-86-73-06-12-70

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923537256
SDNAIndex:448
Count:4
DataHash:31-F5-04-A3-41-F4-3C-52-60-35-09-1B-7E-91-4D-7E

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016927461720
SDNAIndex:457
Count:1
DataHash:7E-B9-23-B6-29-0A-B7-C1-31-34-26-57-17-03-53-26

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923160696
SDNAIndex:450
Count:1
DataHash:19-74-83-53-E4-80-31-C5-B4-95-6B-98-2B-1E-E3-5E

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923534632
SDNAIndex:448
Count:4
DataHash:31-F5-04-A3-41-F4-3C-52-60-35-09-1B-7E-91-4D-7E

==== File Block ====

Identifier:BR
DataLength:2072
MemoryAddress:2016927477064
SDNAIndex:457
Count:1
DataHash:55-C4-15-93-5A-52-79-EC-58-89-70-77-1C-56-3A-69

==== File Block ====

Identifier:DATA
DataLength:384
MemoryAddress:2016923161096
SDNAIndex:450
Count:1
DataHash:E6-65-AD-B7-34-AE-36-AA-34-84-92-19-BF-6A-A2-5C

==== File Block ====

Identifier:DATA
DataLength:48
MemoryAddress:2016923537512
SDNAIndex:448
Count:4
DataHash:31-F5-04-A3-41-F4-3C-52-60-35-09-1B-7E-91-4D-7E

==== File Block ====

Identifier:GD
DataLength:160
MemoryAddress:2016923127368
SDNAIndex:482
Count:1
DataHash:49-60-09-2C-35-E1-5A-3B-C4-1D-75-43-98-0E-0B-40

==== File Block ====

Identifier:LS
DataLength:464
MemoryAddress:2016918155592
SDNAIndex:603
Count:1
DataHash:65-40-48-AF-3F-00-BE-5D-9B-E5-78-18-15-21-F3-3D

==== File Block ====

Identifier:DATA
DataLength:104
MemoryAddress:2016918687912
SDNAIndex:588
Count:1
DataHash:FF-2B-9A-9B-30-93-66-FD-11-BE-BE-94-8F-CE-48-EA

==== File Block ====

Identifier:DNA1
DataLength:87008
MemoryAddress:2016994660392
SDNAIndex:0
Count:1
DataHash:18-EB-BA-4B-D5-A0-FC-ED-DB-61-29-99-A4-CE-DA-26

==== File Block ====

Identifier:ENDB
DataLength:0
MemoryAddress:0
SDNAIndex:0
Count:0
DataHash:D4-1D-8C-D9-8F-00-B2-04-E9-80-09-98-EC-F8-42-7E

=13px

Last Edited By: jaundice Feb 4 16 10:37 PM. Edited 3 times.

Quote    Reply   

#5 [url]

Aug 22 16 1:14 AM

This video talks about how to use opencv with blender project https://vimeo.com/126676834 use this python code for opencv

diffImage.cols, CV_8UC1);

float threshold = 30.0f;
float dist;

for(int j=0; j for(int i=0; i {
cv::Vec3b pix = diffImage.at(j,i);

dist = (pix[0]*pix[0] + pix[1]*pix[1] + pix[2]*pix[2]);
dist = sqrt(dist);

if(dist>threshold)
{
foregroundMask.at(j,i) = 255;
}
}

One problem in your code is cv::threshold which only uses 1 channel images. Finding the pixelwise "difference" between two images in only grayscale often leads to unintuitive results.
Since your provided images are a bit translated or the camera wasnt stationary, I've manipulated your background image to add some foreground:
background image:

foreground image:

code:
cv::Mat diffImage;
cv::absdiff(backgroundImage, currentImage, diffImage);

cv::Mat foregroundMask = cv::Mat::zeros(diffImage.rows, diffImage.cols, CV_8UC1);

float threshold = 30.0f;
float dist;

for(int j=0; j for(int i=0; i {
cv::Vec3b pix = diffImage.at(j,i);

dist = (pix[0]*pix[0] + pix[1]*pix[1] + pix[2]*pix[2]);
dist = sqrt(dist);

if(dist>threshold)
{
foregroundMask.at(j,i) = 255;
}
}
giving this result:

with this difference image:

in general it is hard to compute a complete foreground/background segmentation from pixel-wise difference interpretations.
You will probably have to add postprocessing stuff to get a real segmentation, where you start from your foreground mask. Not sure whether there are any stable universal solutions yet.
As berak mentioned, in practice it won't be enough to use a single background image, so you will have to compute/manage your background image over time. There are plenty of papers covering this topic and afaik no stable universal solution yet.
here are some more tests. I converted to HSV color space: cv::cvtColor(backgroundImage, HSVbackgroundImagebg, CV_BGR2HSV); cv::cvtColor(currentImage, HSV_currentImage, CV_BGR2HSV); and performed the same operations in this space... Credit to http://stackoverflow.com/questions/27035672/cv-extract-differences-between-two-images

Quote    Reply   
Add Reply

Quick Reply

bbcode help